Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: sandbox/win/src/sync_policy.cc

Issue 13912024: Fix small race in the sandbox (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sandbox/win/src/registry_policy.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "sandbox/win/src/sync_policy.h" 7 #include "sandbox/win/src/sync_policy.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "sandbox/win/src/ipc_tags.h" 10 #include "sandbox/win/src/ipc_tags.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return false; 73 return false;
74 74
75 HANDLE local_handle = ::CreateEvent(NULL, manual_reset, initial_state, 75 HANDLE local_handle = ::CreateEvent(NULL, manual_reset, initial_state,
76 event_name.c_str()); 76 event_name.c_str());
77 if (NULL == local_handle) 77 if (NULL == local_handle)
78 return ::GetLastError(); 78 return ::GetLastError();
79 79
80 if (!::DuplicateHandle(::GetCurrentProcess(), local_handle, 80 if (!::DuplicateHandle(::GetCurrentProcess(), local_handle,
81 client_info.process, handle, 0, FALSE, 81 client_info.process, handle, 0, FALSE,
82 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { 82 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) {
83 ::CloseHandle(local_handle);
84 return ERROR_ACCESS_DENIED; 83 return ERROR_ACCESS_DENIED;
85 } 84 }
86 return ERROR_SUCCESS; 85 return ERROR_SUCCESS;
87 } 86 }
88 87
89 DWORD SyncPolicy::OpenEventAction(EvalResult eval_result, 88 DWORD SyncPolicy::OpenEventAction(EvalResult eval_result,
90 const ClientInfo& client_info, 89 const ClientInfo& client_info,
91 const std::wstring &event_name, 90 const std::wstring &event_name,
92 uint32 desired_access, 91 uint32 desired_access,
93 uint32 inherit_handle, 92 uint32 inherit_handle,
94 HANDLE *handle) { 93 HANDLE *handle) {
95 // The only action supported is ASK_BROKER which means create the requested 94 // The only action supported is ASK_BROKER which means create the requested
96 // file as specified. 95 // file as specified.
97 if (ASK_BROKER != eval_result) 96 if (ASK_BROKER != eval_result)
98 return false; 97 return false;
99 98
100 HANDLE local_handle = ::OpenEvent(desired_access, FALSE, 99 HANDLE local_handle = ::OpenEvent(desired_access, FALSE,
101 event_name.c_str()); 100 event_name.c_str());
102 if (NULL == local_handle) 101 if (NULL == local_handle)
103 return ::GetLastError(); 102 return ::GetLastError();
104 103
105 if (!::DuplicateHandle(::GetCurrentProcess(), local_handle, 104 if (!::DuplicateHandle(::GetCurrentProcess(), local_handle,
106 client_info.process, handle, 0, inherit_handle, 105 client_info.process, handle, 0, inherit_handle,
107 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { 106 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) {
108 ::CloseHandle(local_handle);
109 return ERROR_ACCESS_DENIED; 107 return ERROR_ACCESS_DENIED;
110 } 108 }
111 return ERROR_SUCCESS; 109 return ERROR_SUCCESS;
112 } 110 }
113 111
114 } // namespace sandbox 112 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/registry_policy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698