- Issue #13703: oCERT-2011-003: add -R command-line option and PYTHONHASHSEED

environment variable, to provide an opt-in way to protect against denial of
  service attacks due to hash collisions within the dict and set types.  Patch
  by David Malcolm, based on work by Victor Stinner.
This commit is contained in:
Barry Warsaw 2012-02-20 20:42:21 -05:00
parent f5a5beb339
commit 1e13eb084f
27 changed files with 706 additions and 152 deletions

View file

@ -742,22 +742,3 @@ try:
_make_statvfs_result)
except NameError: # statvfs_result may not exist
pass
if not _exists("urandom"):
def urandom(n):
"""urandom(n) -> str
Return a string of n random bytes suitable for cryptographic use.
"""
try:
_urandomfd = open("/dev/urandom", O_RDONLY)
except (OSError, IOError):
raise NotImplementedError("/dev/urandom (or equivalent) not found")
try:
bs = b""
while n - len(bs) >= 1:
bs += read(_urandomfd, n - len(bs))
finally:
close(_urandomfd)
return bs