https://gcc.gnu.org/g:8faef9e741d5e11e4146067a4bbbe1fdfb100178

commit r17-4426-g8faef9e741d5e11e4146067a4bbbe1fdfb100178
Author: Xavier Del Campo Romero <[email protected]>
Date:   Thu Sep 17 22:47:40 2026 +0200

    cobol: Do not null-terminate original string in CBL_CREATE_FILE.cbl
    
    This can cause undefined behaviour if the string supplied by the caller
    cannot be modified e.g.: string literals.
    
    libgcobol/ChangeLog:
    
            * compat/gnu/lib/CBL_CREATE_FILE.cbl: Do not null-terminate
            original string.

Diff:
---
 libgcobol/compat/gnu/lib/CBL_CREATE_FILE.cbl | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/libgcobol/compat/gnu/lib/CBL_CREATE_FILE.cbl 
b/libgcobol/compat/gnu/lib/CBL_CREATE_FILE.cbl
index 80fbef21a1ab..15b44cd3c85f 100644
--- a/libgcobol/compat/gnu/lib/CBL_CREATE_FILE.cbl
+++ b/libgcobol/compat/gnu/lib/CBL_CREATE_FILE.cbl
@@ -47,7 +47,6 @@
        77  func-ret             Binary-Long.
        77  errno-val            Binary-Long.
        77  lk-mode              PIC 9(8) COMP-5.
-       77  filename-len         PIC 9(4) BINARY VALUE ZERO.
        01  ws-access-mode       PIC 9(8) COMP-5.
 
        LINKAGE SECTION.
@@ -69,9 +68,6 @@
                SUBTRACT 64 FROM ws-access-mode *> Remove large file bit if set
            END-IF.
 
-           COMPUTE filename-len =
-                FUNCTION LENGTH(FUNCTION TRIM(filename)).
-           MOVE X"00" TO filename(filename-len + 1:1).
       D     Display 'CBL_CREATE_FILE: filename: [' filename ']'
       D     Display               'ws-access-mode: ' ws-access-mode ', '
       D     Display                 'deny-mode: ' deny-mode.

Reply via email to