소스 검색

Merge branch 'ticket21953_029' into maint-0.2.9

Nick Mathewson 6 년 전
부모
커밋
c928fb988a
2개의 변경된 파일15개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 0
      changes/ticket21953
  2. 9 1
      src/or/main.c

+ 6 - 0
changes/ticket21953

@@ -0,0 +1,6 @@
+  o Minor features:
+    - Enable a couple of pieces of Windows hardening: one
+      (HeapEnableTerminationOnCorruption) that has been on-by-default since
+      Windows 8, and unavailable before Windows 7, and one
+      (PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION) which we believe doesn't
+      affect us, but shouldn't do any harm. Closes ticket 21953.

+ 9 - 1
src/or/main.c

@@ -3426,6 +3426,11 @@ tor_main(int argc, char *argv[])
   int result = 0;
   int result = 0;
 
 
 #ifdef _WIN32
 #ifdef _WIN32
+#ifndef HeapEnableTerminationOnCorruption
+#define HeapEnableTerminationOnCorruption 1
+#endif
+  /* On heap corruption, just give up; don't try to play along. */
+  HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
   /* Call SetProcessDEPPolicy to permanently enable DEP.
   /* Call SetProcessDEPPolicy to permanently enable DEP.
      The function will not resolve on earlier versions of Windows,
      The function will not resolve on earlier versions of Windows,
      and failure is not dangerous. */
      and failure is not dangerous. */
@@ -3434,7 +3439,10 @@ tor_main(int argc, char *argv[])
     typedef BOOL (WINAPI *PSETDEP)(DWORD);
     typedef BOOL (WINAPI *PSETDEP)(DWORD);
     PSETDEP setdeppolicy = (PSETDEP)GetProcAddress(hMod,
     PSETDEP setdeppolicy = (PSETDEP)GetProcAddress(hMod,
                            "SetProcessDEPPolicy");
                            "SetProcessDEPPolicy");
-    if (setdeppolicy) setdeppolicy(1); /* PROCESS_DEP_ENABLE */
+    if (setdeppolicy) {
+      /* PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION */
+      setdeppolicy(3);
+    }
   }
   }
 #endif
 #endif