Turn on hash randomization in the version of python bundled with calibre

This commit is contained in:
Kovid Goyal 2014-09-29 21:36:33 +05:30
parent 880c889a23
commit b4cfdbbf32
3 changed files with 5 additions and 0 deletions

View File

@ -183,6 +183,7 @@ void initialize_interpreter(int argc, char **argv, char *outr, char *errr,
Py_NoUserSiteDirectory = 1;
Py_VerboseFlag = 0;
Py_DebugFlag = 0;
Py_HashRandomizationFlag = 1;
Py_SetProgramName(exe_path);
Py_SetPythonHome(base_dir);

View File

@ -55,6 +55,7 @@ void initialize_interpreter(const char **ENV_VARS, const char **ENV_VAR_VALS,
Py_DontWriteBytecodeFlag = 1;
Py_IgnoreEnvironmentFlag = 1;
Py_NoUserSiteDirectory = 1;
Py_HashRandomizationFlag = 1;
//Py_VerboseFlag = 1;
//Py_DebugFlag = 1;

View File

@ -319,6 +319,9 @@ void initialize_interpreter(wchar_t *outr, wchar_t *errr,
flag = (int*)GetProcAddress(dll, "Py_NoUserSiteDirectory");
if (!flag) ExitProcess(_show_error(L"Failed to get user_site flag", L"", 1));
*flag = 1;
flag = (int*)GetProcAddress(dll, "Py_HashRandomizationFlag ");
if (!flag) ExitProcess(_show_error(L"Failed to get hash randomization flag", L"", 1));
*flag = 1;
flag = (int*)GetProcAddress(dll, "Py_VerboseFlag");
if (!flag) ExitProcess(_show_error(L"Failed to get verbose flag", L"", 1));
//*flag = 1;