Here is a patch for some stability bugs I ran into when developing
namebench. This fixes issues similar to
http://www.mail-archive.com/[email protected]/msg00002.html
- as well as:
File "/usr/local/lib/python2.6/site-packages/dns/entropy.py", line
62, in random_8
self.stir(self.digest)
File "/usr/local/lib/python2.6/site-packages/dns/entropy.py", line 54, in stir
bytes[self.pool_index] ^= b
IndexError: list index out of range
I'm not sure about the cryptographic correctness of it, but it's
removed all stability issues we've had:
--- /tmp/dnspython-1.7.1/dns/entropy.py 2009-06-18 12:17:04.000000000 +0200
+++ third_party/dns/entropy.py 2010-01-06 13:40:19.000000000 +0100
@@ -48,7 +48,7 @@
def stir(self, entropy):
bytes = [ord(c) for c in self.pool]
for c in entropy:
- if self.pool_index == self.hash_len:
+ if self.pool_index == self.hash_len or self.pool_index >=
len(bytes)-1:
self.pool_index = 0
b = ord(c) & 0xff
bytes[self.pool_index] ^= b
@@ -56,11 +56,12 @@
self.pool = ''.join([chr(c) for c in bytes])
def random_8(self):
- if self.digest is None or self.next_byte == self.hash_len:
+ if self.digest is None or self.next_byte == self.hash_len or
self.next_byte >= len(self.digest)-1:
self.hash.update(self.pool)
self.digest = self.hash.digest()
self.stir(self.digest)
self.next_byte = 0
+
value = ord(self.digest[self.next_byte])
self.next_byte += 1
return value
This patch is also available at
http://sprocket.io/files/dnspython-1.7.1-entropy.py-stability.patch
Many thanks for this excellent library. namebench would have never
been written if it was not for the hard work you guys put into it.
--
// thomas
_______________________________________________
dnspython-bugs mailing list
[email protected]
http://howl.play-bow.org/mailman/listinfo.cgi/dnspython-bugs