Mercurial > cpython-lru_cache-weakref
diff Python/sysmodule.c @ 75073:4a31f6b11e7a 3.2
Merge from 3.1: Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
in order to make algorithmic complexity attacks on (e.g.) web apps much more complicated.
The environment variable PYTHONHASHSEED and the new command line flag -R control this
behavior.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Mon, 20 Feb 2012 21:31:46 +0100 |
| parents | fdcda5b74317 f4b7ecf8a5f8 |
| children | ed76dc34b39d |
line wrap: on
line diff
--- a/Python/sysmodule.c Mon Feb 20 18:35:26 2012 +0000 +++ b/Python/sysmodule.c Mon Feb 20 21:31:46 2012 +0100 @@ -1368,6 +1368,7 @@ /* {"skip_first", "-x"}, */ {"bytes_warning", "-b"}, {"quiet", "-q"}, + {"hash_randomization", "-R"}, {0} }; @@ -1376,9 +1377,9 @@ flags__doc__, /* doc */ flags_fields, /* fields */ #ifdef RISCOS - 13 + 14 #else - 12 + 13 #endif }; @@ -1412,6 +1413,7 @@ /* SetFlag(skipfirstline); */ SetFlag(Py_BytesWarningFlag); SetFlag(Py_QuietFlag); + SetFlag(Py_HashRandomizationFlag); #undef SetFlag if (PyErr_Occurred()) {
