[or-cvs] assert that nobody asks for a random number between 0 and -1

Roger Dingledine arma at seul.org
Wed Dec 3 08:08:09 UTC 2003


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common

Modified Files:
	crypto.c 
Log Message:
assert that nobody asks for a random number between 0 and -1


Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- crypto.c	12 Nov 2003 04:28:30 -0000	1.43
+++ crypto.c	3 Dec 2003 08:08:07 -0000	1.44
@@ -1013,6 +1013,7 @@
   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



More information about the tor-commits mailing list