summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-06-06 16:18:24 -0400
committerNick Mathewson <nickm@torproject.org>2011-06-06 16:18:24 -0400
commit9e3fc5f61685f937d76e60c5fa1781b80aa5bf68 (patch)
treea0ed38fbbf3f5534352afba28e3bc97366b82c31 /src/common/crypto.c
parent83e3975c8bebb3f0aeb95d672e09d31797f7bd6a (diff)
parent42e4e156d95a1c28a666a5346d491c4ed71435dd (diff)
downloadtor-9e3fc5f61685f937d76e60c5fa1781b80aa5bf68.tar.gz
tor-9e3fc5f61685f937d76e60c5fa1781b80aa5bf68.zip
Merge branch 'bug3306_nm_squashed' into maint-0.2.2
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r--src/common/crypto.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index d8e6619c9f..851f11bf3b 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -2145,13 +2145,14 @@ crypto_rand(char *to, size_t n)
}
/** Return a pseudorandom integer, chosen uniformly from the values
- * between 0 and <b>max</b>-1. */
+ * between 0 and <b>max</b>-1 inclusive. <b>max</b> must be between 1 and
+ * INT_MAX+1, inclusive. */
int
crypto_rand_int(unsigned int max)
{
unsigned int val;
unsigned int cutoff;
- tor_assert(max < UINT_MAX);
+ tor_assert(max <= ((unsigned int)INT_MAX)+1);
tor_assert(max > 0); /* don't div by 0 */
/* We ignore any values that are >= 'cutoff,' to avoid biasing the