summaryrefslogtreecommitdiff
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-02-20 19:54:16 +0100
committerGeorg Brandl <georg@python.org>2012-02-20 19:54:16 +0100
commit2daf6ae2495c862adf8bc717bfe9964081ea0b10 (patch)
treeebd7efe668e4f7842c6d51bdbde47b00f92a57db /Python/sysmodule.c
parentec1712a1662282c909b4cd4cc0c7486646bc9246 (diff)
downloadcpython-git-2daf6ae2495c862adf8bc717bfe9964081ea0b10.tar.gz
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.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index c688172dac..6a7e91432c 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1126,6 +1126,7 @@ static PyStructSequence_Field flags_fields[] = {
/* {"unbuffered", "-u"}, */
/* {"skip_first", "-x"}, */
{"bytes_warning", "-b"},
+ {"hash_randomization", "-R"},
{0}
};
@@ -1134,9 +1135,9 @@ static PyStructSequence_Desc flags_desc = {
flags__doc__, /* doc */
flags_fields, /* fields */
#ifdef RISCOS
- 12
+ 13
#else
- 11
+ 12
#endif
};
@@ -1169,6 +1170,7 @@ make_flags(void)
/* SetFlag(saw_unbuffered_flag); */
/* SetFlag(skipfirstline); */
SetFlag(Py_BytesWarningFlag);
+ SetFlag(Py_HashRandomizationFlag);
#undef SetFlag
if (PyErr_Occurred()) {