]> git.ipfire.org Git - thirdparty/coreutils.git/commit
cksum: use more exact selection of digest algorithms
authorPádraig Brady <P@draigBrady.com>
Sun, 30 Jan 2022 20:19:48 +0000 (20:19 +0000)
committerPádraig Brady <P@draigBrady.com>
Sun, 30 Jan 2022 23:13:52 +0000 (23:13 +0000)
commita42a0391329313482e0cee61c78b69e6c1500cad
treec921d8eeca0b8d228ea553a6cd71231e7b2166c9
parent703e0487e4b3237cc77ae21b19bfde9ff30f8126
cksum: use more exact selection of digest algorithms

Use more constrained argument matching
to improve forward compatibility and robustness.

For example it's better that `cksum -a sha3` is _not_
equivalent to `cksum -a sha386`, so that a user
specifying `-a sha3` on an older cksum would not be surprised.

Also argmatch() is used when parsing tags from lines like:
SHA3 (filename) = abcedf....
so it's more robust that older cksum instances to fail
earlier in the parsing process, when parsing output from
possible future cksum implementations that might support SHA3.

* src/digest.c (algorithm_from_tag): Use argmatch_exact()
to ensure we don't match abbreviated algorithms.
(main): Likewise.
* tests/misc/cksum-a.sh: Add a test case.
src/digest.c
tests/misc/cksum-a.sh