From 9d333aca433c5c7ae988d262130eb7e0c81819cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sat, 22 Apr 2023 15:59:48 +0100 Subject: 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. --- NEWS | 3 +++ src/cksum.c | 8 +------- src/cksum_pclmul.c | 8 +------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index 8edfa8080..a8db32246 100644 --- a/NEWS +++ b/NEWS @@ -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); } -- cgit v1.2.1