mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 15:32:10 +08:00
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.
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user