* src/digest.c (main): Don't saturate -l to BLAKE2B_MAX_LEN,
so that the subsequent bounds check is performed.
* tests/cksum/b2sum.sh: Add a test case.
* NEWS: Mention the fix introduced in commit v9.5-71-gf2c84fe63
---
NEWS | 4 ++++
src/digest.c | 2 +-
tests/cksum/b2sum.sh | 3 +++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index f2e7c9e6e..988cb96a8 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU coreutils NEWS -*-
outline -*-
** Bug fixes
+ 'b2sum' will diagnose --length values that are too big.
+ Previously it would have silently assumed 512 for any larger values.
+ [bug introduced in coreutils-9.6]
+
'basenc -d -i' will now strip '=' characters from the input
in encodings where padding characters are not valid.
[bug introduced with the basenc program in coreutils-8.31]
diff --git a/src/digest.c b/src/digest.c
index 302739e9f..0e4e62dee 100644
--- a/src/digest.c
+++ b/src/digest.c
@@ -1402,7 +1402,7 @@ main (int argc, char **argv)
#endif
#if HASH_ALGO_BLAKE2 || HASH_ALGO_CKSUM
case 'l':
- digest_length = xnumtoumax (optarg, 10, 0, BLAKE2B_MAX_LEN * 8, "",
+ digest_length = xnumtoumax (optarg, 10, 0, UINTMAX_MAX, "",
_("invalid length"), 0,
XTOINT_MAX_QUIET);
digest_length_str = optarg;
diff --git a/tests/cksum/b2sum.sh b/tests/cksum/b2sum.sh
index af3ead798..d240f7df9 100755
--- a/tests/cksum/b2sum.sh
+++ b/tests/cksum/b2sum.sh
@@ -69,6 +69,9 @@ returns_ 1 $prog -c overflow.check || fail=1
# Only validate the last specified, used length
$prog -l 123 -l 128 /dev/null || fail=1
+# This would not flag an error in coreutils 9.6 and 9.7
+returns_ 1 $prog -l 1024 /dev/null || fail=1
+
done
Exit $fail
--
2.50.1