Skip to content
Snippets Groups Projects
Commit 465a85fb authored by Brad King's avatar Brad King
Browse files

librhash: Avoid signed left-shift overflow

Fix `rhash_md5_final` to use unsigned integers for left shifting to
avoid the possibility of undefined overflow behavior.
parent fc2cb74f
No related branches found
No related tags found
No related merge requests found
......@@ -213,8 +213,8 @@ void rhash_md5_final(md5_ctx *ctx, unsigned char* result)
/* pad message and run for last block */
/* append the byte 0x80 to the message */
ctx->message[index] &= ~(0xFFFFFFFF << shift);
ctx->message[index++] ^= 0x80 << shift;
ctx->message[index] &= ~(0xFFFFFFFFu << shift);
ctx->message[index++] ^= 0x80u << shift;
/* if no room left in the message to store 64-bit message length */
if (index > 14) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment