diff --git a/NEWS b/NEWS index b6b5201e7..7fb8c5363 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,11 @@ GNU coreutils NEWS -*- outline -*- and the system supported set of valid speeds. [This bug was present in "the beginning".] + `wc -c` will again efficiently determine the size of large files + on all systems. It no longer redundantly reads data from certain + sized files larger than SIZE_MAX. + [bug introduced in coreutils-8.24] + ** Changes in behavior 'cp --reflink=always A B' no longer leaves behind a newly created diff --git a/src/wc.c b/src/wc.c index bc52a8c0e..df9770396 100644 --- a/src/wc.c +++ b/src/wc.c @@ -431,7 +431,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos) if (! fstatus->failed && usable_st_size (&fstatus->st) && 0 <= fstatus->st.st_size) { - size_t end_pos = fstatus->st.st_size; + off_t end_pos = fstatus->st.st_size; if (current_pos < 0) current_pos = lseek (fd, 0, SEEK_CUR); diff --git a/tests/misc/wc-proc.sh b/tests/misc/wc-proc.sh index 581890ddd..030872a91 100755 --- a/tests/misc/wc-proc.sh +++ b/tests/misc/wc-proc.sh @@ -42,4 +42,11 @@ cat <<\EOF > exp EOF compare exp out || fail=1 +# Ensure we don't read too much when reading, +# as was the case on 32 bit systems +# from coreutils-8.24 to coreutils-9.1 +if timeout 10 truncate -s1T do_read; then + timeout 10 wc -c do_read || fail=1 +fi + Exit $fail