diff options
author | Jim Meyering <jim@meyering.net> | 2000-06-24 07:37:44 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-06-24 07:37:44 +0000 |
commit | a6e6a1e05b5ea28e8f8b3696c0e7748923cb1da4 (patch) | |
tree | 89e52c57b0c6859f87b773ac3c8c367b44d4a51b | |
parent | 1cc0f0d268856926666d6c09d69ba0b4990dcff1 (diff) | |
download | coreutils-a6e6a1e05b5ea28e8f8b3696c0e7748923cb1da4.tar.xz |
(sysv_sum_file): Avoid overflowing 32-bit accumulator
on files larger than 256 MB.
-rw-r--r-- | src/sum.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -176,6 +176,9 @@ sysv_sum_file (const char *file, int print_name) for (i = 0; i < bytes_read; i++) checksum += buf[i]; + /* Reduce checksum mod 0xffff, to avoid overflow. */ + checksum = (checksum & 0xffff) + (checksum >> 16); + total_bytes += bytes_read; } |