mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Avoid negating unsigned values
This commit is contained in:
@@ -140,7 +140,7 @@ randombytes_uniform(const uint32_t upper_bound)
|
||||
if (upper_bound < 2) {
|
||||
return 0;
|
||||
}
|
||||
min = (uint32_t) (-upper_bound % upper_bound);
|
||||
min = (1U + ~upper_bound) % upper_bound;
|
||||
do {
|
||||
r = randombytes_random();
|
||||
} while (r < min);
|
||||
|
||||
Reference in New Issue
Block a user