You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is that a maximum length of 256 is hardcoded, but the maximum filename length is a very complex issue. 256 could be too much or too little depending on the operating system, the file system, and even what directory the file is created in. The solution is that the code handling input/output filenames should pass around an alloc storage duration buffer and dynamically grow it as needed throughout the program's execution. Then, when the file is finally created, the system will return error if it fails to create the file.
Also, that code didn't have to be a macro.
#229 partly fixes this bug along with a host of other bugs.
There is much more code around handling filenames which needs to be read carefully to check if it's free from this bug or not. The code that handles the output file and its filename is extremely buggy as many issues attest: #241#244#246#228#226#223
The text was updated successfully, but these errors were encountered:
N-R-K
added a commit
to N-R-K/scrot
that referenced
this issue
May 6, 2023
256 (or NAME_MAX) is not a reliable constant. furthermore, the
"fileName" in this case can be a full path as well, so checking against
NAME_MAX would be wrong regardless.
Closes: resurrecting-open-source-projects#247
Scrot uses this macro to check if input/output filenames are within a certain size:
scrot/src/options.c
Lines 61 to 66 in 70a7540
scrot/src/options.c
Line 76 in 70a7540
The issue is that a maximum length of 256 is hardcoded, but the maximum filename length is a very complex issue. 256 could be too much or too little depending on the operating system, the file system, and even what directory the file is created in. The solution is that the code handling input/output filenames should pass around an alloc storage duration buffer and dynamically grow it as needed throughout the program's execution. Then, when the file is finally created, the system will return error if it fails to create the file.
Also, that code didn't have to be a macro.
#229 partly fixes this bug along with a host of other bugs.
There is much more code around handling filenames which needs to be read carefully to check if it's free from this bug or not. The code that handles the output file and its filename is extremely buggy as many issues attest: #241 #244 #246 #228 #226 #223
The text was updated successfully, but these errors were encountered: