summaryrefslogtreecommitdiffstats
path: root/sandbox/win/src/process_policy_test.cc
diff options
context:
space:
mode:
authorrnk <rnk@chromium.org>2016-02-17 09:57:36 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-17 17:59:47 +0000
commitd603de8096aa0c6cf804167958202379d59a6c65 (patch)
treec85b52f73fa46dfafb07272312d1bf8c47bfa5f9 /sandbox/win/src/process_policy_test.cc
parentca1a84a4317d95b08569838882b67fa0ceb9fd8d (diff)
downloadchromium_src-d603de8096aa0c6cf804167958202379d59a6c65.zip
chromium_src-d603de8096aa0c6cf804167958202379d59a6c65.tar.gz
chromium_src-d603de8096aa0c6cf804167958202379d59a6c65.tar.bz2
Fix calling convention mismatch for ::CreateThread callback
ASan intercepts CreateThread, and if the calling convention is wrong, ESP will end up off by 4, leading to a wild return. A classic mistake that Microsoft appears to tolerate sometimes: https://blogs.msdn.microsoft.com/oldnewthing/20040115-00/?p=41043 TBR=thakis@chromium.org,liamjm@chromium.org,jschuh@chromium.org Review URL: https://codereview.chromium.org/1702403002 Cr-Commit-Position: refs/heads/master@{#375920}
Diffstat (limited to 'sandbox/win/src/process_policy_test.cc')
-rw-r--r--sandbox/win/src/process_policy_test.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/sandbox/win/src/process_policy_test.cc b/sandbox/win/src/process_policy_test.cc
index e97a16f..8062d46 100644
--- a/sandbox/win/src/process_policy_test.cc
+++ b/sandbox/win/src/process_policy_test.cc
@@ -283,7 +283,7 @@ std::wstring GenerateEventName(DWORD pid) {
// This is the function that is called when testing thread creation.
// It is expected to set an event that the caller is waiting on.
-DWORD TestThreadFunc(LPVOID lpdwThreadParam) {
+DWORD WINAPI TestThreadFunc(LPVOID lpdwThreadParam) {
std::wstring event_name = GenerateEventName(
static_cast<DWORD>(reinterpret_cast<uintptr_t>(lpdwThreadParam)));
if (!event_name.length()) {
@@ -313,7 +313,7 @@ SBOX_TESTS_COMMAND int Process_CreateThread(int argc, wchar_t** argv) {
DWORD thread_id = 0;
HANDLE thread = NULL;
- thread = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&TestThreadFunc,
+ thread = ::CreateThread(NULL, 0, &TestThreadFunc,
reinterpret_cast<LPVOID>(static_cast<uintptr_t>(pid)),
0, &thread_id);
@@ -501,7 +501,7 @@ TEST(ProcessPolicyTest, TestCreateThreadOutsideSandbox) {
DWORD thread_id = 0;
HANDLE thread = NULL;
thread = TargetCreateThread(
- ::CreateThread, NULL, 0, (LPTHREAD_START_ROUTINE)&TestThreadFunc,
+ ::CreateThread, NULL, 0, &TestThreadFunc,
reinterpret_cast<LPVOID>(static_cast<uintptr_t>(pid)), 0, &thread_id);
EXPECT_NE(static_cast<HANDLE>(NULL), thread);
EXPECT_EQ(WAIT_OBJECT_0, WaitForSingleObject(thread, INFINITE));