Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cksum: incomplete hex checksum is treated as mismatch instead of improper format #6576

Open
BenWiederhake opened this issue Jul 16, 2024 · 3 comments · Fixed by #6868 · May be fixed by #6606
Open

cksum: incomplete hex checksum is treated as mismatch instead of improper format #6576

BenWiederhake opened this issue Jul 16, 2024 · 3 comments · Fixed by #6868 · May be fixed by #6606

Comments

@BenWiederhake
Copy link
Collaborator

When checking a cksum-file, hexstrings that have the wrong length are reported as mismatching errors instead of simply broken formatting. (Arguably, they should be treated as errors for safety, but I guess it's better to stick with GNU behavior here.)

$ cat sums
BLAKE2b (LICENSE) = e45898002c601e57504d0a7d7cb7ea5a1bc58d2f9a94fde09f370045ba2b3d57cbd26c3b0df1b4023b08c8b101303bb1b1b7c3363b38085194c1067c487a3052
BLAKE2b (build.rs) = ab3ec55005267c4d6333c585a313d424dc3fffc4f5b29aa335724d444bf6a9b26234b9db506e92b48dc76800248fffe618889d45a7b3b5228baca2ff7e2db3e
BLAKE2b (README.md) = c0a230cfdbbb686f91071119c915a19df28cb2e4fc575f19d5c6b81bf4e3ca2e83e6df49f14d8b89ece14eb4090be435a7af6fed2c981774e076caa8fe62b0
$ cksum -c sums
LICENSE: OK
cksum: WARNING: 2 lines are improperly formatted
$ cargo run -q cksum -c sums
LICENSE: OK
build.rs: FAILED
README.md: FAILED
cksum: WARNING: 2 computed checksums did NOT match
[$? = 1]

This isn't specific to blake2b:

$ cat sums
SHA256 (LICENSE) = 29953405eaa3dcc41c37d1621d55b6a47eee93e05613e439e73295029740b10c
SHA256 (build.rs) = 299aa98fed9979a78d4022c9993ac19a5c647167b4e85ba7af2240d91ea759d
SHA256 (README.md) = 4d9b4c7b50b976ec5b0b2dce5a767d2da4b63eb68592017d475c4e11799a33
$ cksum -c sums
LICENSE: OK
cksum: WARNING: 2 lines are improperly formatted
$ cargo run -q cksum -c sums
LICENSE: OK
build.rs: FAILED
README.md: FAILED
cksum: WARNING: 2 computed checksums did NOT match
[$? = 1]

Found while reviewing #6499, although it's not the cause of this bug. (The expected_checksum.len() / 2 expression looks suspicious, though.)

@cakebaker
Copy link
Contributor

Reopening this ticket as it was closed by accident due to merging #6868 .

@cakebaker cakebaker reopened this Nov 26, 2024
@sylvestre
Copy link
Contributor

i don't think it is covered by upstream tests btw as we are at 100 % coverage here:
https://uutils.github.io/coreutils/docs/test_coverage.html

@RenjiSann
Copy link
Contributor

i don't think it is covered by upstream tests btw as we are at 100 % coverage here: https://uutils.github.io/coreutils/docs/test_coverage.html

There are indeed several cases that are not tested correctly by the GNU testsuite, namely all the issues we found, even though we pass all the GNU tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants