Skip to content

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

@BenWiederhake

Description

@BenWiederhake

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions