Add _ENCODE_FILE_EXISTING variable#5
Conversation
Signed-off-by: sabi789 <sabithac6298@gmail.com>
🤖 Augment PR SummarySummary: Adds a new environment variable to control how existing files are tagged/translated when opened through the zoslib CLIB overrides. Changes:
🤖 Was this summary useful? React with 👍 or 👎 |
| .B _ENCODE_FILE_NEW=BINARY | ||
|
|
||
| .TP | ||
| .B _ENCODE_FILE_NEW=UTF-8 |
There was a problem hiding this comment.
man/zoslib.1:26: The BINARY description line ("New files are created without translation and are tagged as BINARY.") now appears after the UTF-8 stanza, so it likely renders as the UTF-8 description and leaves the BINARY option undocumented.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| New files are created without translation and are tagged as BINARY. | ||
|
|
||
| .TP | ||
| .B _ENCODE_FILE_EXISTING=ISO8859-1 |
There was a problem hiding this comment.
man/zoslib.1:33: Marking _ENCODE_FILE_EXISTING=ISO8859-1 as "(Default)" seems inconsistent with the implementation (when _ENCODE_FILE_EXISTING is unset, __tag_existing_file() is a no-op and existing file behavior depends on the file’s current tag/heuristics).
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| } | ||
| // Enable auto-conversion of untagged files | ||
| else if (S_ISREG(sb.st_mode)) { | ||
| __tag_existing_file(fd); |
There was a problem hiding this comment.
src/zos-io.cc:894: After retagging the FD via _ENCODE_FILE_EXISTING, the auto-conversion decision still consults sb.st_tag from the pre-open stat(), so previously-untagged files can still trigger the heuristic and enable conversion (potentially overriding _ENCODE_FILE_EXISTING, especially BINARY).
Severity: high
Other Locations
src/zos-io.cc:939
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| read(fd, buff2, sizeof(buff)); | ||
|
|
||
| // Delete and re-open temp_path _ENCODE_FILE_NEW=UTF-8 | ||
| setenv("_ENCODE_FILE_NEW", "UTF-8", 1); |
There was a problem hiding this comment.
test/test-clib-override.cc:184: The fd from the preceding ISO8859-1 open(temp_path, O_RDONLY) isn’t closed before remove()/reusing fd, and the later UTF-8 open(temp_path, O_RDONLY) also isn’t closed; this can leak descriptors and make the test flaky.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| fd = open(temp_path, O_RDONLY); | ||
| EXPECT_EQ(__getfdccsid(fd), 0x10000 + 1047); | ||
| memset(buff2, 1, sizeof(buff)); | ||
| read(fd, buff2, sizeof(buff)); |
There was a problem hiding this comment.
test/test-clib-override.cc:208: These tests don’t check the return value from read() and then use strcmp(buff, buff2); if a short read occurs, buff2 may not be NUL-terminated and strcmp can read past the buffer (undefined behavior).
Severity: medium
Other Locations
test/test-clib-override.cc:194test/test-clib-override.cc:217test/test-clib-override.cc:226test/test-clib-override.cc:235
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
No description provided.