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

Unified Diff: sandbox/win/src/broker_services.cc

Issue 1227163008: Sandbox: Make PolicyBase::MakeTokens return ScopedHandes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sandbox/win/src/sandbox_policy_base.h » ('j') | sandbox/win/src/sandbox_policy_base.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/win/src/broker_services.cc
diff --git a/sandbox/win/src/broker_services.cc b/sandbox/win/src/broker_services.cc
index dbf75f967ec9d82ddc7000b38ecf2020034551f5..fbb790206c854bb9087592af042997a8d9250f41 100644
--- a/sandbox/win/src/broker_services.cc
+++ b/sandbox/win/src/broker_services.cc
@@ -357,8 +357,8 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path,
// Construct the tokens and the job object that we are going to associate
// with the soon to be created target process.
- HANDLE initial_token_temp;
- HANDLE lockdown_token_temp;
+ base::win::ScopedHandle initial_token;
+ base::win::ScopedHandle lockdown_token;
ResultCode result = SBOX_ALL_OK;
if (IsTokenCacheable(policy_base)) {
@@ -367,37 +367,39 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path,
// process launch.
uint32_t token_key = GenerateTokenCacheKey(policy_base);
TokenCacheMap::iterator it = token_cache_.find(token_key);
+ HANDLE initial_token_temp;
+ HANDLE lockdown_token_temp;
if (it != token_cache_.end()) {
initial_token_temp = it->second.first;
lockdown_token_temp = it->second.second;
} else {
- result =
- policy_base->MakeTokens(&initial_token_temp, &lockdown_token_temp);
+ result = policy_base->MakeTokens(&initial_token, &lockdown_token);
if (SBOX_ALL_OK != result)
return result;
token_cache_[token_key] =
- std::pair<HANDLE, HANDLE>(initial_token_temp, lockdown_token_temp);
+ std::make_pair(initial_token.Get(), lockdown_token.Get());
+ initial_token_temp = initial_token.Take();
+ lockdown_token_temp = lockdown_token.Take();
}
if (!::DuplicateToken(initial_token_temp, SecurityImpersonation,
&initial_token_temp)) {
return SBOX_ERROR_GENERIC;
}
+ initial_token.Set(initial_token_temp);
if (!::DuplicateTokenEx(lockdown_token_temp, TOKEN_ALL_ACCESS, 0,
SecurityIdentification, TokenPrimary,
&lockdown_token_temp)) {
return SBOX_ERROR_GENERIC;
}
+ lockdown_token.Set(lockdown_token_temp);
} else {
- result = policy_base->MakeTokens(&initial_token_temp, &lockdown_token_temp);
+ result = policy_base->MakeTokens(&initial_token, &lockdown_token);
if (SBOX_ALL_OK != result)
return result;
}
- base::win::ScopedHandle initial_token(initial_token_temp);
- base::win::ScopedHandle lockdown_token(lockdown_token_temp);
-
HANDLE job_temp;
result = policy_base->MakeJobObject(&job_temp);
if (SBOX_ALL_OK != result)
« no previous file with comments | « no previous file | sandbox/win/src/sandbox_policy_base.h » ('j') | sandbox/win/src/sandbox_policy_base.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698