[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] cksum: fix failure to diagnose read errors with crc32
From: |
Pádraig Brady |
Subject: |
[PATCH] cksum: fix failure to diagnose read errors with crc32 |
Date: |
Sat, 22 Apr 2023 17:08:40 +0100 |
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 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);
}
--
2.26.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] cksum: fix failure to diagnose read errors with crc32,
Pádraig Brady <=