Commit 05b9c351 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

assert that nobody asks for a random number between 0 and -1

parent f65e871b
......@@ -1013,6 +1013,7 @@ int crypto_pseudo_rand_int(unsigned int max) {
unsigned int val;
unsigned int cutoff;
assert(max < UINT_MAX);
assert(max > 0); /* don't div by 0 */
/* We ignore any values that are >= 'cutoff,' to avoid biasing the
* distribution with clipping at the upper end of unsigned int's
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment