From b4cfdbbf32333f2f6cd4a38193493962e27d63dc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 29 Sep 2014 21:36:33 +0530 Subject: [PATCH] Turn on hash randomization in the version of python bundled with calibre --- setup/installer/linux/util.c | 1 + setup/installer/osx/app/util.c | 1 + setup/installer/windows/util.c | 3 +++ 3 files changed, 5 insertions(+) diff --git a/setup/installer/linux/util.c b/setup/installer/linux/util.c index b06d6083c9..c619cec16f 100644 --- a/setup/installer/linux/util.c +++ b/setup/installer/linux/util.c @@ -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); diff --git a/setup/installer/osx/app/util.c b/setup/installer/osx/app/util.c index a3dbc35d16..b8e1e360fd 100644 --- a/setup/installer/osx/app/util.c +++ b/setup/installer/osx/app/util.c @@ -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; diff --git a/setup/installer/windows/util.c b/setup/installer/windows/util.c index 5ed6bbce69..310938d3e0 100644 --- a/setup/installer/windows/util.c +++ b/setup/installer/windows/util.c @@ -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;