Mercurial > cpython-lru_cache-weakref
diff Python/sysmodule.c @ 75066:f4b7ecf8a5f8 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 19:54:16 +0100 |
| parents | febb6cf195e7 |
| children | 4a31f6b11e7a |
line wrap: on
line diff
--- a/Python/sysmodule.c Sat Feb 18 14:42:57 2012 +0100 +++ b/Python/sysmodule.c Mon Feb 20 19:54:16 2012 +0100 @@ -1126,6 +1126,7 @@ /* {"unbuffered", "-u"}, */ /* {"skip_first", "-x"}, */ {"bytes_warning", "-b"}, + {"hash_randomization", "-R"}, {0} }; @@ -1134,9 +1135,9 @@ flags__doc__, /* doc */ flags_fields, /* fields */ #ifdef RISCOS - 12 + 13 #else - 11 + 12 #endif }; @@ -1169,6 +1170,7 @@ /* SetFlag(saw_unbuffered_flag); */ /* SetFlag(skipfirstline); */ SetFlag(Py_BytesWarningFlag); + SetFlag(Py_HashRandomizationFlag); #undef SetFlag if (PyErr_Occurred()) {
