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

librhash: Avoid signed left-shift overflow in sha256

Fix `rhash_sha256_final` to use unsigned integers for left shifting to
avoid the possibility of undefined overflow behavior.
parent d0ff3e70
No related branches found
No related tags found
No related merge requests found
......@@ -218,8 +218,8 @@ void rhash_sha256_final(sha256_ctx *ctx, unsigned char* result)
/* pad message and run for last block */
/* append the byte 0x80 to the message */
ctx->message[index] &= le2me_32(~(0xFFFFFFFF << shift));
ctx->message[index++] ^= le2me_32(0x80 << shift);
ctx->message[index] &= le2me_32(~(0xFFFFFFFFu << shift));
ctx->message[index++] ^= le2me_32(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