]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/csrand.c: Fix the lower part of the domain of csrand_uniform()
authorAlejandro Colomar <alx@kernel.org>
Wed, 19 Jun 2024 17:54:16 +0000 (19:54 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 21 Jun 2024 02:38:58 +0000 (21:38 -0500)
commit47edcd3045fd2865cbcdcb002f52195a960b3dda
treed9b4cd7dad3275b634896e5d924b7498b6bfa393
parentcde08e422d8c179d4ba622da2290c31ec645c611
lib/csrand.c: Fix the lower part of the domain of csrand_uniform()

I accidentally broke this code during an un-optimization.  We need to
start from a random value of the width of the limit, that is, 32 bits.

Thanks to Jason for pointing to his similar code in the kernel, which
made me see my mistake.

Fixes: 2a61122b5e8f ("Unoptimize the higher part of the domain of csrand_uniform()")
Closes: <https://github.com/shadow-maint/shadow/issues/1015>
Reported-by: Michael Brunnbauer <https://github.com/michaelbrunnbauer>
Link: <https://git.zx2c4.com/linux-rng/tree/drivers/char/random.c#n535>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Link: <https://github.com/shadow-maint/shadow/pull/638>
Link: <https://github.com/shadow-maint/shadow/issues/634>
Link: <https://github.com/shadow-maint/shadow/pull/624>
Tested-by: Michael Brunnbauer <https://github.com/michaelbrunnbauer>
Reviewed-by: Michael Brunnbauer <https://github.com/michaelbrunnbauer>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/csrand.c