diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2007-10-18 08:34:20 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2007-10-18 08:34:20 (GMT) |
commit | f8a2a0b5a9edc5769b2da40c36c49eed4c5c1b33 (patch) | |
tree | 93ccc9d0db73bbf7fe09123610195eab615cb153 /Lib | |
parent | afed3a4552e0df61477c322f60b10d3ae59edf1c (diff) | |
download | cpython-f8a2a0b5a9edc5769b2da40c36c49eed4c5c1b33.zip cpython-f8a2a0b5a9edc5769b2da40c36c49eed4c5c1b33.tar.gz cpython-f8a2a0b5a9edc5769b2da40c36c49eed4c5c1b33.tar.bz2 |
Fix a weird bug in dbtables: if it chose a random rowid string that contained
NULL bytes it would cause the database all sorts of problems in the future
leading to very strange random failures and corrupt dbtables.bsdTableDb dbs.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/bsddb/dbtables.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/bsddb/dbtables.py b/Lib/bsddb/dbtables.py index daf6a9e..37a12c8 100644 --- a/Lib/bsddb/dbtables.py +++ b/Lib/bsddb/dbtables.py @@ -22,7 +22,6 @@ import sys import copy import random import struct -import base64 from types import ListType, StringType import cPickle as pickle @@ -361,11 +360,12 @@ class bsdTableDB : unique = 0 while not unique: # Generate a random 64-bit row ID string - # (note: this code has <64 bits of randomness + # (note: this code has <56 bits of randomness # but it's plenty for our database id needs!) + # The | 0x01010101 is to ensure no null bytes are in the value newid = struct.pack('ll', - random.randint(0, 2147483647), - random.randint(0, 2147483647)) + random.randint(0, 2147483647) | 0x01010101, + random.randint(0, 2147483647) | 0x01010101) # Guarantee uniqueness by adding this key to the database try: |