summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authormaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-24 12:58:37 +0000
committermaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-24 12:58:37 +0000
commitc9d40877fb0df5306deac35ff176a02c667d90e8 (patch)
tree07e1e03a75ac5637ebc5543d73366ce29b2854bf /base
parent025517044b4be3ab45efc2f383e5a7b830aa7281 (diff)
downloadchromium_src-c9d40877fb0df5306deac35ff176a02c667d90e8.zip
chromium_src-c9d40877fb0df5306deac35ff176a02c667d90e8.tar.gz
chromium_src-c9d40877fb0df5306deac35ff176a02c667d90e8.tar.bz2
Enforce Terminate on Heap Corruption in most of our executable on Windows XP SP3 or Vista.
This won't submit the crash dump but it's still better than nothing. Fix broken alignment on test_shell_main.cc. Review URL: http://codereview.chromium.org/3105 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2546 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/process_util.h4
-rw-r--r--base/process_util_posix.cc4
-rw-r--r--base/process_util_win.cc5
-rw-r--r--base/run_all_unittests.cc3
4 files changed, 15 insertions, 1 deletions
diff --git a/base/process_util.h b/base/process_util.h
index 1a50e4a..e5e3e92 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -258,6 +258,10 @@ class ProcessMetrics {
// Note: Returns true on Windows 2000 without doing anything.
bool EnableLowFragmentationHeap();
+// Enable 'terminate on heap corruption' flag. Helps protect against heap
+// overflow. Has no effect if the OS doesn't provide the necessary facility.
+void EnableTerminationOnHeapCorruption();
+
// If supported on the platform, and the user has sufficent rights, increase
// the current process's scheduling priority to a high priority.
void RaiseProcessToHighPriority();
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index 96f05bb..4d2f1e5 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -23,6 +23,10 @@ int GetProcId(ProcessHandle process) {
return process;
}
+void EnableTerminationOnHeapCorruption() {
+ // On POSIX, there nothing to do AFAIK.
+}
+
void RaiseProcessToHighPriority() {
// On POSIX, we don't actually do anything here. We could try to nice() or
// setpriority() or sched_getscheduler, but these all require extra rights.
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 24689a1..b464336 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -598,6 +598,11 @@ bool EnableLowFragmentationHeap() {
return true;
}
+void EnableTerminationOnHeapCorruption() {
+ // Ignore the result code. Supported on XP SP3 and Vista.
+ HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
+}
+
void RaiseProcessToHighPriority() {
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
}
diff --git a/base/run_all_unittests.cc b/base/run_all_unittests.cc
index c0b131f..4ab019a 100644
--- a/base/run_all_unittests.cc
+++ b/base/run_all_unittests.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/process_util.h"
#include "base/test_suite.h"
int main(int argc, char** argv) {
+ process_util::EnableTerminationOnHeapCorruption();
return TestSuite(argc, argv).Run();
}
-