Skip to content

Commit

Permalink
Update md5.c
Browse files Browse the repository at this point in the history
The read from data is promoted to int, and so the left shift by 24 in md5.c may cause signed overflow. This requires cast to an unsigned int:

B-Con#33
  • Loading branch information
taeasy authored Jul 13, 2024
1 parent 7752b1e commit a4c9953
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void md5_transform(MD5_CTX *ctx, const BYTE data[])
// endian byte order CPU. Reverse all the bytes upon input, and re-reverse them
// on output (in md5_final()).
for (i = 0, j = 0; i < 16; ++i, j += 4)
m[i] = (data[j]) + (data[j + 1] << 8) + (data[j + 2] << 16) + (data[j + 3] << 24);
m[i] = (data[j]) + (data[j + 1] << 8) + (data[j + 2] << 16) + ((WORD)data[j + 3] << 24);

a = ctx->state[0];
b = ctx->state[1];
Expand Down

0 comments on commit a4c9953

Please sign in to comment.