Repository navigation
pathchk: reject a 256-byte file name with -p, like GNU - #16312
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
| // path length | ||
| if total_len > POSIX_PATH_MAX { | ||
| // path length: _POSIX_PATH_MAX counts the terminating null byte, so the | ||
| // longest portable file name is one byte shorter, as in GNU pathchk |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| let total_len = joined_path.len(); | ||
| // path length | ||
| if total_len > POSIX_PATH_MAX { | ||
| // path length: _POSIX_PATH_MAX counts the terminating null byte, so the |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| #[test] | ||
| #[cfg(unix)] | ||
| fn test_posix_mode_path_max() { |
There was a problem hiding this comment.
We might already have subset of this test which can be improved.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
|
||
| // _POSIX_PATH_MAX (256) includes the terminating null byte, so 255 bytes | ||
| // is the longest portable file name | ||
| let path_of_len = |len: usize| { |
There was a problem hiding this comment.
this closure seems a bit complex for a test, something like format!("{}a", "a/".repeat(127)) would do, no?
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
_POSIX_PATH_MAX (256) counts the terminating null byte, so with -p the longest portable file name is 255 bytes. A 256-byte name was accepted, and a longer one was reported against limit 256 with the name unquoted. Report limit 255 and quote the name, as GNU pathchk does.
a64003c to
2c8a795
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
Thanks for your PR |
pathchk -paccepted a 256-byte file name._POSIX_PATH_MAX(256) counts the terminating null byte, so the longest portable name is 255 bytes, and GNU rejects 256. For longer names the error also saidlimit 256and printed the name without quotes, unlike the default-mode message.The check is now
>= POSIX_PATH_MAX, the reported limit isPOSIX_PATH_MAX - 1and the name is quoted, which matches GNU for 255, 256 and 257 byte names.Test:
test_posix_mode_path_max(255 bytes passes, 256 fails with the GNU message). It fails on main and passes with the fix;cargo fmtandcargo clippy -p uu_pathchk --all-targets -D warningsare clean.I used an AI assistant to help find and write this change; I reviewed it and checked it against GNU pathchk.