diff options
| author | Pádraig Brady <P@draigBrady.com> | 2025-10-06 13:23:55 +0100 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2025-10-07 15:58:34 +0100 |
| commit | cd2a8edd84a6b6a17ba1b788a6b3930c5a4d590e (patch) | |
| tree | bfbaa9d7bc9de34a1fdab9d1ee966d4e1eea4f75 /src | |
| parent | rm: remove redundant mark_ancestor_dirs call (diff) | |
| download | coreutils-cd2a8edd84a6b6a17ba1b788a6b3930c5a4d590e.tar.gz coreutils-cd2a8edd84a6b6a17ba1b788a6b3930c5a4d590e.zip | |
cksum: fix --check with --algorithm=sha2
* src/digest.c (split_3): Look up the provided tag with -a sha2
because there is not a 1:1 mapping between them.
* tests/cksum/cksum-c.sh: Add a test case.
* NEWS: Mention the bug fix.
Diffstat (limited to 'src')
| -rw-r--r-- | src/digest.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/digest.c b/src/digest.c index 13b166795..86119b5ab 100644 --- a/src/digest.c +++ b/src/digest.c @@ -843,16 +843,20 @@ split_3 (char *s, size_t s_len, /* Check for BSD-style checksum line. */ #if HASH_ALGO_CKSUM - if (! algorithm_specified) + if (! algorithm_specified || cksum_algorithm == sha2) { ptrdiff_t algo_tag = algorithm_from_tag (s + i); if (algo_tag >= 0) { if (algo_tag <= crc32b) return false; /* We don't support checking these older formats. */ + if (cksum_algorithm == sha2 && algo_tag != sha2 + && algo_tag != sha224 && algo_tag != sha256 + && algo_tag != sha384 && algo_tag != sha512) + return false; /* Wrong tag for -a sha2. */ cksum_algorithm = algo_tag; } - else + else if (! algorithm_specified) return false; /* We only support tagged format without -a. */ } #endif |
