From 465a85fb4615f4cfa20058c534bf3bfe71df1732 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 9 Nov 2016 11:43:34 -0500 Subject: 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. --- Utilities/cmlibrhash/librhash/md5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utilities/cmlibrhash/librhash/md5.c b/Utilities/cmlibrhash/librhash/md5.c index 0feb090..b20de45 100644 --- a/Utilities/cmlibrhash/librhash/md5.c +++ b/Utilities/cmlibrhash/librhash/md5.c @@ -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) { -- cgit v0.12