[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Fix longstanding, obscure, and probably harmless bug in...
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv23310/lib/mixminion
Modified Files:
Crypto.py
Log Message:
Fix longstanding, obscure, and probably harmless bug in RNG.getInt().
(This bug was noticed when I tried to adapt the logic for Tor, and
realized that the logic was wrong.)
Index: Crypto.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Crypto.py,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- Crypto.py 25 Aug 2003 21:05:34 -0000 1.54
+++ Crypto.py 12 Nov 2003 04:35:14 -0000 1.55
@@ -568,6 +568,7 @@
assert 0 < max < 0x3fffffff
_ord = ord
+ cutoff = 0x7fffffff - (0x7fffffff % max)
while 1:
# Get a random positive int between 0 and 0x7fffffff.
b = self.getBytes(4)
@@ -577,7 +578,7 @@
_ord(b[3]))
# Retry if we got a value that would fall in an incomplete
# run of 'max' elements.
- if 0x7fffffff - max >= o:
+ if o < cutoff:
return o % max
def getNormal(self, m, s):