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

Side by Side Diff: content/common/sandbox_win.cc

Issue 1372153002: Detecting and fixing stringprintf.h format bugs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed four mismatches that I missed Created 5 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/sandbox_win.h" 5 #include "content/common/sandbox_win.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Eviction of injected DLLs is done by the sandbox so that the injected module 217 // Eviction of injected DLLs is done by the sandbox so that the injected module
218 // does not get a chance to execute any code. 218 // does not get a chance to execute any code.
219 void AddGenericDllEvictionPolicy(sandbox::TargetPolicy* policy) { 219 void AddGenericDllEvictionPolicy(sandbox::TargetPolicy* policy) {
220 for (int ix = 0; ix != arraysize(kTroublesomeDlls); ++ix) 220 for (int ix = 0; ix != arraysize(kTroublesomeDlls); ++ix)
221 BlacklistAddOneDll(kTroublesomeDlls[ix], true, policy); 221 BlacklistAddOneDll(kTroublesomeDlls[ix], true, policy);
222 } 222 }
223 223
224 // Returns the object path prepended with the current logon session. 224 // Returns the object path prepended with the current logon session.
225 base::string16 PrependWindowsSessionPath(const base::char16* object) { 225 base::string16 PrependWindowsSessionPath(const base::char16* object) {
226 // Cache this because it can't change after process creation. 226 // Cache this because it can't change after process creation.
227 static uintptr_t s_session_id = 0; 227 static uint64_t s_session_id = 0;
Will Harris 2015/09/29 00:29:17 This should be DWORD, since GetTokenInformation wi
brucedawson 2015/09/29 21:39:40 Done.
228 if (s_session_id == 0) { 228 if (s_session_id == 0) {
229 HANDLE token; 229 HANDLE token;
230 DWORD session_id_length; 230 DWORD session_id_length;
231 DWORD session_id = 0; 231 DWORD session_id = 0;
232 232
233 CHECK(::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)); 233 CHECK(::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token));
234 CHECK(::GetTokenInformation(token, TokenSessionId, &session_id, 234 CHECK(::GetTokenInformation(token, TokenSessionId, &session_id,
235 sizeof(session_id), &session_id_length)); 235 sizeof(session_id), &session_id_length));
236 CloseHandle(token); 236 CloseHandle(token);
237 if (session_id) 237 if (session_id)
238 s_session_id = session_id; 238 s_session_id = session_id;
239 } 239 }
240 240
241 return base::StringPrintf(L"\\Sessions\\%d%ls", s_session_id, object); 241 return base::StringPrintf(L"\\Sessions\\%llu%ls", s_session_id, object);
Will Harris 2015/09/29 00:29:17 %lu seems sensible here?
brucedawson 2015/09/29 21:39:40 If s_session_id is a DWORD then %lu does seem best
242 } 242 }
243 243
244 // Checks if the sandbox should be let to run without a job object assigned. 244 // Checks if the sandbox should be let to run without a job object assigned.
245 bool ShouldSetJobLevel(const base::CommandLine& cmd_line) { 245 bool ShouldSetJobLevel(const base::CommandLine& cmd_line) {
246 if (!cmd_line.HasSwitch(switches::kAllowNoSandboxJob)) 246 if (!cmd_line.HasSwitch(switches::kAllowNoSandboxJob))
247 return true; 247 return true;
248 248
249 // Windows 8 allows nested jobs so we don't need to check if we are in other 249 // Windows 8 allows nested jobs so we don't need to check if we are in other
250 // job. 250 // job.
251 if (base::win::GetVersion() >= base::win::VERSION_WIN8) 251 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 } 867 }
868 868
869 return false; 869 return false;
870 } 870 }
871 871
872 bool BrokerAddTargetPeer(HANDLE peer_process) { 872 bool BrokerAddTargetPeer(HANDLE peer_process) {
873 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; 873 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK;
874 } 874 }
875 875
876 } // namespace content 876 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698