aboutsummaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-05-11 16:39:02 -0400
committerNick Mathewson <nickm@torproject.org>2017-05-11 16:39:02 -0400
commit503f101d2b1d8dfdd17cc2aa79fc10d79eecd04c (patch)
tree5558d78d4ce4cbe8dfc7450a47caff921c822d53 /src/or/main.c
parent8f5da804da5a8cd486478f8bf2fea1f47a025225 (diff)
downloadtor-503f101d2b1d8dfdd17cc2aa79fc10d79eecd04c.tar.gz
tor-503f101d2b1d8dfdd17cc2aa79fc10d79eecd04c.zip
Enable some windows hardening features
One (HeapEnableTerminationOnCorruption) is on-by-default since win8; the other (PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION) supposedly only affects ATL, which (we think) we don't use. Still, these are good hygiene. Closes ticket 21953.
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 66a8571901..2de8ed29ac 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -3426,6 +3426,8 @@ tor_main(int argc, char *argv[])
int result = 0;
#ifdef _WIN32
+ /* On heap corruption, just give up; don't try to play along. */
+ HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
/* Call SetProcessDEPPolicy to permanently enable DEP.
The function will not resolve on earlier versions of Windows,
and failure is not dangerous. */
@@ -3434,7 +3436,10 @@ tor_main(int argc, char *argv[])
typedef BOOL (WINAPI *PSETDEP)(DWORD);
PSETDEP setdeppolicy = (PSETDEP)GetProcAddress(hMod,
"SetProcessDEPPolicy");
- if (setdeppolicy) setdeppolicy(1); /* PROCESS_DEP_ENABLE */
+ if (setdeppolicy) {
+ /* PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION */
+ setdeppolicy(3);
+ }
}
#endif