From 12897d7d395f5907e0f9a3694ba3c64c329db0dd Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 20 Feb 2012 23:49:29 +0100 Subject: [PATCH 1/4] Fix typo in conditional. --- Python/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/random.c b/Python/random.c index 327166e26aa..01cd83aa564 100644 --- a/Python/random.c +++ b/Python/random.c @@ -269,7 +269,7 @@ _PyRandom_Init(void) */ env = Py_GETENV("PYTHONHASHSEED"); - if (env && *env != '\0' & strcmp(env, "random") != 0) { + if (env && *env != '\0' && strcmp(env, "random") != 0) { char *endptr = env; unsigned long seed; seed = strtoul(env, &endptr, 10); From 06b1c4f68bca367bf2a2c8ce9bf36168ccb2f9ef Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 20 Feb 2012 23:09:59 +0100 Subject: [PATCH 2/4] Fix typo. --- Misc/NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index 486da13674d..0d23663867d 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -11,7 +11,7 @@ Core and Builtins ----------------- - Issue #13703: oCERT-2011-003: add -R command-line option and PYTHONHASHSEED - environment variables, to provide an opt-in way to protect against denial of + 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. From 7c573f7a075fd8fc7bf90bdbcc4f163cda3b9acf Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 20 Feb 2012 22:48:06 +0100 Subject: [PATCH 3/4] Fix dbm_gnu test relying on set order. --- Lib/test/test_dbm_gnu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py index 2173b92afa9..f77dcfe49a1 100755 --- a/Lib/test/test_dbm_gnu.py +++ b/Lib/test/test_dbm_gnu.py @@ -49,7 +49,7 @@ class TestGdbm(unittest.TestCase): all = set(gdbm.open_flags) # Test standard flags (presumably "crwn"). modes = all - set('fsu') - for mode in modes: + for mode in sorted(modes): # put "c" mode first self.g = gdbm.open(filename, mode) self.g.close() From 9571155ae4ff86b4275950fcdfadcc76475943e3 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 20 Feb 2012 22:06:02 +0100 Subject: [PATCH 4/4] Remove setting hash seed to regrtest's random seed and re-execv()ing: this doesn't preserve Python flags and fails from a temp directory. --- Lib/test/regrtest.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index d203600e295..98d68bd1b48 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -428,11 +428,6 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, except ValueError: print("Couldn't find starting test (%s), using all tests" % start) if randomize: - hashseed = os.getenv('PYTHONHASHSEED') - if not hashseed: - os.environ['PYTHONHASHSEED'] = str(random_seed) - os.execv(sys.executable, [sys.executable] + sys.argv) - return random.seed(random_seed) print("Using random seed", random_seed) random.shuffle(tests)