mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
assert that nobody asks for a random number between 0 and -1
svn:r875
This commit is contained in:
parent
f65e871bfd
commit
05b9c35173
@ -1013,6 +1013,7 @@ int crypto_pseudo_rand_int(unsigned int max) {
|
|||||||
unsigned int val;
|
unsigned int val;
|
||||||
unsigned int cutoff;
|
unsigned int cutoff;
|
||||||
assert(max < UINT_MAX);
|
assert(max < UINT_MAX);
|
||||||
|
assert(max > 0); /* don't div by 0 */
|
||||||
|
|
||||||
/* We ignore any values that are >= 'cutoff,' to avoid biasing the
|
/* We ignore any values that are >= 'cutoff,' to avoid biasing the
|
||||||
* distribution with clipping at the upper end of unsigned int's
|
* distribution with clipping at the upper end of unsigned int's
|
||||||
|
Loading…
Reference in New Issue
Block a user