diff options
author | Pádraig Brady <P@draigBrady.com> | 2023-04-22 15:59:48 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2023-04-24 11:46:28 +0100 |
commit | 9d333aca433c5c7ae988d262130eb7e0c81819cf (patch) | |
tree | 96a1cf8cfec210a4128aabc6514b38d802b58c90 | |
parent | e29f4411c80b38a8d146de9ceb0d7e85831b72f3 (diff) | |
download | coreutils-9d333aca433c5c7ae988d262130eb7e0c81819cf.tar.gz |
cksum: fix failure to diagnose read errors with crc32
The default crc32 mode fails to diagnose read errors.
* src/cksum.c (cksum_slice8): Fix the check for read errors.
(cksum_pclmul): Likewise.
* NEWS: Mention the bug fix.
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/cksum.c | 8 | ||||
-rw-r--r-- | src/cksum_pclmul.c | 8 |
3 files changed, 5 insertions, 14 deletions
@@ -4,6 +4,9 @@ GNU coreutils NEWS -*- outline -*- ** Bug fixes + cksum again diagnoses read errors in its default CRC32 mode. + [bug introduced in coreutils-9.0] + install --strip now supports installing to files with a leading hyphen. Previously such file names would have caused the strip process to fail. [This bug was present in "the beginning".] diff --git a/src/cksum.c b/src/cksum.c index 75d82e62c..85afab0ac 100644 --- a/src/cksum.c +++ b/src/cksum.c @@ -212,12 +212,6 @@ cksum_slice8 (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out) } length += bytes_read; - if (bytes_read == 0) - { - if (ferror (fp)) - return false; - } - /* Process multiples of 8 bytes */ datap = (uint32_t *)buf; while (bytes_read >= 8) @@ -247,7 +241,7 @@ cksum_slice8 (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out) *crc_out = crc; *length_out = length; - return true; + return !ferror (fp); } /* Calculate the checksum and length in bytes of stream STREAM. diff --git a/src/cksum_pclmul.c b/src/cksum_pclmul.c index 9c6e4df54..9dba1c912 100644 --- a/src/cksum_pclmul.c +++ b/src/cksum_pclmul.c @@ -77,12 +77,6 @@ cksum_pclmul (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out) } length += bytes_read; - if (bytes_read == 0) - { - if (ferror (fp)) - return false; - } - datap = (__m128i *)buf; /* Fold in parallel eight 16-byte blocks into four 16-byte blocks */ @@ -191,5 +185,5 @@ cksum_pclmul (FILE *fp, uint_fast32_t *crc_out, uintmax_t *length_out) *crc_out = crc; *length_out = length; - return true; + return !ferror (fp); } |