When verifying a checksum file (b2sum -c, or cksum -a blake2b --check), uutils derives the BLAKE2b output length from the digest written in the file and passes it straight to the hasher without validating it against the 64-byte maximum. A check line whose digest decodes to more than 64 bytes — for a file that exists — makes blake2b_simd::Params::hash_length fail its assert!(length <= 64) and abort the whole run.
$ mkdir t && cd t
$ echo data > f1 # the file named in the check line must exist
$ printf '%s f1\n' "$(printf 'ab%.0s' $(seq 65))" > sums # 65-byte (130-hex) "digest", filename f1
$ b2sum -c sums
thread 'main' panicked at blake2b_simd-1.0.4/src/lib.rs:239:9:
Bad hash length: 65
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo $?
134
Any digest length > 64 bytes reproduces it. cksum -a blake2b --check sums takes the same path.
$ cksum -a blake2b --check sums
thread 'main' panicked at blake2b_simd-1.0.4/src/lib.rs:239:9:
Bad hash length: 65
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo $?
134
GNU b2sum -c rejects the same file gracefully.
$ b2sum -c sums # GNU coreutils
b2sum: sums: no properly formatted BLAKE2 checksum lines found
$ echo $?
0
Root cause
The --length/-l CLI path is validated (parse_blake_length rejects > 512 bits), but the checksum-file path is not: process_non_algo_based_line sets algo_byte_len = Some(expected_checksum.len()) (src/uucore/src/lib/features/checksum/validate.rs:794) and hands it to SizedAlgoKind::from_unsized, which stores it unchecked (.../checksum/mod.rs:303, Blake2b(l.unwrap_or(..))). Building the digest then calls Blake2b::with_output_bytes(len) (.../features/sum.rs:96) → blake2b_simd hash_length(len), whose assert! panics for len > 64.
When verifying a checksum file (
b2sum -c, orcksum -a blake2b --check), uutils derives the BLAKE2b output length from the digest written in the file and passes it straight to the hasher without validating it against the 64-byte maximum. A check line whose digest decodes to more than 64 bytes — for a file that exists — makesblake2b_simd::Params::hash_lengthfail itsassert!(length <= 64)and abort the whole run.Any digest length
> 64bytes reproduces it.cksum -a blake2b --check sumstakes the same path.GNU
b2sum -crejects the same file gracefully.Root cause
The
--length/-lCLI path is validated (parse_blake_lengthrejects> 512bits), but the checksum-file path is not:process_non_algo_based_linesetsalgo_byte_len = Some(expected_checksum.len())(src/uucore/src/lib/features/checksum/validate.rs:794) and hands it toSizedAlgoKind::from_unsized, which stores it unchecked (.../checksum/mod.rs:303,Blake2b(l.unwrap_or(..))). Building the digest then callsBlake2b::with_output_bytes(len)(.../features/sum.rs:96) →blake2b_simd hash_length(len), whoseassert!panics forlen > 64.