[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] cksum: fix --check with non tagged format checksums
From: |
Pádraig Brady |
Subject: |
[PATCH] cksum: fix --check with non tagged format checksums |
Date: |
Thu, 16 Sep 2021 12:21:06 +0100 |
* 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.
---
src/digest.c | 2 +-
tests/misc/cksum-a.sh | 21 ++++++++++++++++-----
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/digest.c b/src/digest.c
index fdf01b21b..9ee37a104 100644
--- a/src/digest.c
+++ b/src/digest.c
@@ -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;
diff --git a/tests/misc/cksum-a.sh b/tests/misc/cksum-a.sh
index d6d50ccee..92d84203d 100755
--- a/tests/misc/cksum-a.sh
+++ b/tests/misc/cksum-a.sh
@@ -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
--
2.26.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] cksum: fix --check with non tagged format checksums,
Pádraig Brady <=