mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-08-04 07:43:58 +02:00
cksum: fix --check with non tagged format checksums
* src/digest.c: Always set the digest_length, so that we check the correct number of hex digits when parsing non tagged format checksums. * tests/misc/cksum-a.sh: Add a test case. Also fix up this test which was ineffective due to fail=1 being set in a subshell and ignored.
This commit is contained in:
+1
-1
@@ -1370,7 +1370,7 @@ main (int argc, char **argv)
|
||||
quote (DIGEST_TYPE_STRING),
|
||||
BLAKE2B_MAX_LEN * 8);
|
||||
}
|
||||
if (digest_length == 0 && ! do_check)
|
||||
if (digest_length == 0)
|
||||
{
|
||||
# if HASH_ALGO_BLAKE2
|
||||
digest_length = BLAKE2B_MAX_LEN * 8;
|
||||
|
||||
+16
-5
@@ -19,7 +19,7 @@
|
||||
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
|
||||
print_ver_ cksum
|
||||
|
||||
printf "
|
||||
cat > input_options <<\EOF || framework_failure_
|
||||
bsd sum -r
|
||||
sysv sum -s
|
||||
crc cksum
|
||||
@@ -30,10 +30,21 @@ sha256 sha256sum -t
|
||||
sha384 sha384sum -t
|
||||
sha512 sha512sum -t
|
||||
blake2b b2sum -t
|
||||
" | while read algo prog; do
|
||||
$prog < /dev/null >> out || continue
|
||||
cksum --untagged --algorithm=$algo < /dev/null >> out-a || fail=1
|
||||
done
|
||||
EOF
|
||||
|
||||
while read algo prog; do
|
||||
$prog /dev/null >> out || continue
|
||||
cksum --untagged --algorithm=$algo /dev/null > out-c || fail=1
|
||||
|
||||
case "$algo" in
|
||||
bsd) ;;
|
||||
sysv) ;;
|
||||
crc) ;;
|
||||
*) cksum --check --algorithm=$algo out-c || fail=1 ;;
|
||||
esac
|
||||
|
||||
cat out-c >> out-a || framework_failure_
|
||||
done < input_options
|
||||
compare out out-a || fail=1
|
||||
|
||||
returns_ 1 cksum -a bsd --tag </dev/null
|
||||
|
||||
Reference in New Issue
Block a user