GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
cobol

Cobol: Prevent null-termination of original strings in CBL_CREATE_FILE

Fixes potential UB in CBL_CREATE_FILE by not modifying original strings.

The CBL_CREATE_FILE.cbl implementation has been corrected to avoid null-terminating the original string passed by the caller. This prevents undefined behavior, particularly when the supplied string is a literal or otherwise immutable, ensuring greater stability.

In Details

The libgcobol function CBL_CREATE_FILE previously modified the input string by adding a null terminator. This commit reverts that behavior, as it can lead to undefined behavior if the input string is a string literal or any other memory region that the caller does not expect to be modified. The function now works on a copy if modification is needed.

For Context
Undefined Behavior (UB)
The result of executing code whose behavior is not specified by the C/C++ standards. UB can lead to crashes, incorrect results, or security vulnerabilities.
null-terminate
Adding a null character (\0) to the end of a character array to signify the end of a C-style string.
Filed Under: cobollibgcobolbugfixstability