aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-12-03 08:08:07 +0000
committerRoger Dingledine <arma@torproject.org>2003-12-03 08:08:07 +0000
commit05b9c35173e901825fdd3e5ddd44358942593c0c (patch)
tree55a1b3606218bbc35cf1924ec63f5fb1fbd0b1c1 /src/common
parentf65e871bfd2575a8993e71f4c55fc395934c1b3e (diff)
downloadtor-05b9c35173e901825fdd3e5ddd44358942593c0c.tar
tor-05b9c35173e901825fdd3e5ddd44358942593c0c.tar.gz
assert that nobody asks for a random number between 0 and -1
svn:r875
Diffstat (limited to 'src/common')
-rw-r--r--src/common/crypto.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 551af8964..6b7f0c29f 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -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