Repository navigation
checksum: accept base64 digests only in cksum --check - #16742
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.
Merging this PR will not alter performance1 warning, 1 note
Comparing Footnotes
|
| let verbose = ChecksumVerbose::new(status, quiet, warn); | ||
| let opts = ChecksumValidateOptions { | ||
| allow_empty_filename, | ||
| allow_base64_digest, |
There was a problem hiding this comment.
Adding New variable for this is hacky for me. md5sum --ckeck already have a logic to reject non-md5. No?
There was a problem hiding this comment.
Hi @oech3, thanks for the review! I don't think there is any current logic for rejecting base64 encoding. The existing logic checks the decoded digest, but not the encoding format.
There was a problem hiding this comment.
How does current md5sum --ckeck rejects b2sum as input?
There was a problem hiding this comment.
@oech3 The check that rejects b2sum compares the size of the decoded digest. A base64 MD5 digest decodes to 16 bytes, the same as a hex one, so it passes that check.
There was a problem hiding this comment.
The decoding happens before the size check that rejects b2sum, so that check only sees the decoded bytes:
coreutils/src/uucore/src/lib/features/checksum/validate.rs
Lines 589 to 591 in 3c4d370
|
In this case, I'll admit I'm not sure it's worth adding complexity to the existing code to basically regress the capability of our version just to match with GNU. |
|
Checking a non-md5 by |
|
maybe too many bool ? |
This comment was marked as resolved.
This comment was marked as resolved.
It's not just a feature removal for matching GNU, but also a fix of an hidden bug of wrong result with plain hex input: $ printf 'a\n' > a
$ sha256sum a | sha384sum --checkmain: GNU and this PR: The reason is that the 64 hex digits also happen to be valid |
0a64f50 to
32fe634
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.
Agreed. I will try another design that replacing both bools with one enum for the tool (cksum / b2sum / the others). Let's see if that would work? |
32fe634 to
d2dfb94
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.
The base64 decode, hash, and comparison logic are shared among all the binaries of check sum, so the way to fix it is passing through the difference of each tool down to the shared function. I pushed another style to pass an enum rather than boolean. Does it sound like a better way to you? |
d2dfb94 to
8a92388
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.
8a92388 to
e584ca5
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.
e584ca5 to
570a6e3
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.
570a6e3 to
b7aa5e9
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.
b7aa5e9 to
1bcee41
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.
|
GNU testsuite comparison: |
ChecksumTool names the utility that reads the checksum list, and the rule for an empty file name is now a method of it. The behaviour does not change. Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
md5sum, sha*sum and b2sum read a base64 digest in --check, so a line that GNU reports as improperly formatted gave OK or FAILED. Only cksum reads base64 now, as in GNU. Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
1bcee41 to
cb2a3d6
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 |
Summary
md5sum,sha*sumandb2sumread a base64 digest in--check. GNU reads base64 only incksum, and reports such a line as improperly formatted in the other tools.Example
Before:
After, same as GNU: