Repository navigation
checksum: accept base64 digests only in cksum --check - #16742
ChihweiLHBird wants to merge 1 commit into
Conversation
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>
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 improve performance by 4.33%3 warnings, 1 note
Performance Changes
Tip Curious why performance improved? Comment 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
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: