diff options
author | Sami Kerola | 2014-11-22 01:31:07 +0100 |
---|---|---|
committer | Sami Kerola | 2014-12-19 10:10:48 +0100 |
commit | 95e8d2b3bcc4c276723cbfdb551a4e6152fbb092 (patch) | |
tree | 7142cb2dec06f3bbd08115f8668ddd57655430a8 /lib/crc32.c | |
parent | cal: fix signed integer overflow [AddressSanitizer] (diff) | |
download | kernel-qcow2-util-linux-95e8d2b3bcc4c276723cbfdb551a4e6152fbb092.tar.gz kernel-qcow2-util-linux-95e8d2b3bcc4c276723cbfdb551a4e6152fbb092.tar.xz kernel-qcow2-util-linux-95e8d2b3bcc4c276723cbfdb551a4e6152fbb092.zip |
lib: fix crc32 and crc64 interger overflows [AddressSanitizer]
lib/crc32.c:111:11: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'size_t' (aka 'unsigned long')
lib/crc64.c:101:12: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'size_t' (aka 'unsigned long')
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'lib/crc32.c')
-rw-r--r-- | lib/crc32.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/crc32.c b/lib/crc32.c index eaaa06a0c..be98f1a8d 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -108,8 +108,10 @@ uint32_t crc32(uint32_t seed, const unsigned char *buf, size_t len) uint32_t crc = seed; const unsigned char *p = buf; - while(len-- > 0) + while (len) { crc = crc32_tab[(crc ^ *p++) & 0xff] ^ (crc >> 8); + len--; + } return crc; } |