mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
enable hash randomization by default
This commit is contained in:
parent
6ca5a4d49f
commit
c9f54cf512
9 changed files with 44 additions and 65 deletions
|
@ -73,9 +73,6 @@ static char *usage_2 = "\
|
|||
-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\
|
||||
-OO : remove doc-strings in addition to the -O optimizations\n\
|
||||
-q : don't print version and copyright messages on interactive startup\n\
|
||||
-R : use a pseudo-random salt to make hash() values of various types be\n\
|
||||
unpredictable between separate invocations of the interpreter, as\n\
|
||||
a defence against denial-of-service attacks\n\
|
||||
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\
|
||||
-S : don't imply 'import site' on initialization\n\
|
||||
";
|
||||
|
@ -107,10 +104,10 @@ static char *usage_5 =
|
|||
"PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.\n\
|
||||
";
|
||||
static char *usage_6 = "\
|
||||
PYTHONHASHSEED: if this variable is set to ``random``, the effect is the same \n\
|
||||
as specifying the :option:`-R` option: a random value is used to seed the\n\
|
||||
hashes of str, bytes and datetime objects. It can also be set to an integer\n\
|
||||
in the range [0,4294967295] to get hash values with a predictable seed.\n\
|
||||
PYTHONHASHSEED: if this variable is set to ``random``, a random value is used\n\
|
||||
to seed the hashes of str, bytes and datetime objects. It can also be\n\
|
||||
set to an integer in the range [0,4294967295] to get hash values with a\n\
|
||||
predictable seed.\n\
|
||||
";
|
||||
|
||||
static int
|
||||
|
@ -347,21 +344,13 @@ Py_Main(int argc, wchar_t **argv)
|
|||
not interpreter options. */
|
||||
break;
|
||||
}
|
||||
switch (c) {
|
||||
case 'E':
|
||||
if (c == 'E') {
|
||||
Py_IgnoreEnvironmentFlag++;
|
||||
break;
|
||||
case 'R':
|
||||
Py_HashRandomizationFlag++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* The variable is only tested for existence here; _PyRandom_Init will
|
||||
check its value further. */
|
||||
if (!Py_HashRandomizationFlag &&
|
||||
(p = Py_GETENV("PYTHONHASHSEED")) && *p != '\0')
|
||||
Py_HashRandomizationFlag = 1;
|
||||
|
||||
Py_HashRandomizationFlag = 1;
|
||||
_PyRandom_Init();
|
||||
|
||||
PySys_ResetWarnOptions();
|
||||
|
@ -468,7 +457,7 @@ Py_Main(int argc, wchar_t **argv)
|
|||
break;
|
||||
|
||||
case 'R':
|
||||
/* Already handled above */
|
||||
/* Ignored */
|
||||
break;
|
||||
|
||||
/* This space reserved for other options */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue