projects
/
platform
/
upstream
/
coreutils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1cc0f0d
)
(sysv_sum_file): Avoid overflowing 32-bit accumulator
author
Jim Meyering
<jim@meyering.net>
Sat, 24 Jun 2000 07:37:44 +0000
(07:37 +0000)
committer
Jim Meyering
<jim@meyering.net>
Sat, 24 Jun 2000 07:37:44 +0000
(07:37 +0000)
on files larger than 256 MB.
src/sum.c
patch
|
blob
|
history
diff --git
a/src/sum.c
b/src/sum.c
index
b012182
..
7450931
100644
(file)
--- a/
src/sum.c
+++ b/
src/sum.c
@@
-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;
}