@@ -7046,14 +7046,19 @@ /* uint32_t would be better. But not everyone has inttypes.h? */ unsigned long uA = (unsigned long)wA; const unsigned int S = sizeof(unsigned long) * 8; - wC = (unsigned long)((uA << wB) | (uA >> (S - wB))); + /* Shift left by the word size or more is undefined. */ + wB %= S; + + wC = (unsigned long)(uA << wB) | (uA >> (S - wB)); break; } case JIM_EXPROP_ROTR:{ unsigned long uA = (unsigned long)wA; const unsigned int S = sizeof(unsigned long) * 8; + + wB %= S; wC = (unsigned long)((uA >> wB) | (uA << (S - wB))); break; }