crypto: Fix undefined behavior in random number generator
ubsan reported: ../src/crypto/random.c:69:30: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int' Explicitly check for the ROL32(x, 0) case which is supposed to be a no-op. Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
This commit is contained in:
parent
84fccc7242
commit
333517ac1c
1 changed files with 3 additions and 0 deletions
|
@ -66,6 +66,9 @@ static void random_write_entropy(void);
|
||||||
|
|
||||||
static u32 __ROL32(u32 x, u32 y)
|
static u32 __ROL32(u32 x, u32 y)
|
||||||
{
|
{
|
||||||
|
if (y == 0)
|
||||||
|
return x;
|
||||||
|
|
||||||
return (x << (y & 31)) | (x >> (32 - (y & 31)));
|
return (x << (y & 31)) | (x >> (32 - (y & 31)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue