From 4cec4db7f0c20e4db94ebfb043491bee7843f5b6 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Fri, 8 Feb 2019 23:36:25 +0100 Subject: [PATCH] Fixed undefined behavior in ROR/ROL --- src/crypto/variant4_random_math.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crypto/variant4_random_math.h b/src/crypto/variant4_random_math.h index 50c65f2ed..8724c58c9 100644 --- a/src/crypto/variant4_random_math.h +++ b/src/crypto/variant4_random_math.h @@ -106,13 +106,13 @@ static FORCEINLINE void v4_random_math(const struct V4_Instruction* code, v4_reg case ROR: \ { \ const uint32_t shift = src % REG_BITS; \ - *dst = (*dst >> shift) | (*dst << (REG_BITS - shift)); \ + *dst = (*dst >> shift) | (*dst << ((REG_BITS - shift) % REG_BITS)); \ } \ break; \ case ROL: \ { \ const uint32_t shift = src % REG_BITS; \ - *dst = (*dst << shift) | (*dst >> (REG_BITS - shift)); \ + *dst = (*dst << shift) | (*dst >> ((REG_BITS - shift) % REG_BITS)); \ } \ break; \ case XOR: \