From 5c62f1e1ec8952dc992115103104fb5972ffd98f Mon Sep 17 00:00:00 2001 From: Roy Oursler Date: Thu, 13 Dec 2018 13:33:23 -0700 Subject: [PATCH] crc: Use type cast in crc32_ieee_base to avoid undefined behavior Change-Id: I8362831125927372c62ecb5eec2f5afe6f75ef24 Signed-off-by: Roy Oursler --- crc/crc_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crc/crc_base.c b/crc/crc_base.c index 30c7d81..0f87d72 100644 --- a/crc/crc_base.c +++ b/crc/crc_base.c @@ -165,7 +165,7 @@ uint32_t crc32_ieee_base(uint32_t seed, uint8_t * buf, uint64_t len) uint32_t poly = 0x04C11DB7; // IEEE standard for (i = 0; i < len; i++) { - rem = rem ^ (buf[i] << 24); + rem = rem ^ ((uint64_t) buf[i] << 24); for (j = 0; j < MAX_ITER; j++) { rem = rem << 1; rem = (rem & 0x100000000ULL) ? rem ^ poly : rem;