Skip to content

Commit 3dbd89e

Browse files
authored
sha256: fix undefined-shift error (#2237)
``` third_party/src/ndpi_sha256.c:51:21: runtime error: left shift of 128 by 24 places cannot be represented in type 'int' ``` Found by oss-fuzzer See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65305
1 parent 308f71a commit 3dbd89e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/third_party/src/ndpi_sha256.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void sha256_transform(ndpi_SHA256_CTX *ctx, const u_int8_t data[])
4848
u_int32_t a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
4949

5050
for (i = 0, j = 0; i < 16; ++i, j += 4)
51-
m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]);
51+
m[i] = ((u_int32_t)data[j] << 24) | ((u_int32_t)data[j + 1] << 16) | ((u_int32_t)data[j + 2] << 8) | (data[j + 3]);
5252
for ( ; i < 64; ++i)
5353
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
5454

0 commit comments

Comments
 (0)