Skip to content

Commit

Permalink
Cleanup API usage patterns in process_info_win.cc
Browse files Browse the repository at this point in the history
We're seeing crashes in ::GetProcessTimes() in issue 565905.
While they appear to be in patched binaries we can potentially reduce
their occurrence by at least not passing the same object in three
out-params which aren't documented as being able to share the same
object.

BUG=565905

Review URL: https://codereview.chromium.org/1584213003

Cr-Commit-Position: refs/heads/master@{#369638}
  • Loading branch information
gab authored and Commit bot committed Jan 15, 2016
1 parent ed5d945 commit fd1c593
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions base/process/process_info_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ namespace base {
// static
const Time CurrentProcessInfo::CreationTime() {
FILETIME creation_time = {};
FILETIME ignore = {};
if (::GetProcessTimes(::GetCurrentProcess(), &creation_time, &ignore,
&ignore, &ignore) == false)
FILETIME ignore1 = {};
FILETIME ignore2 = {};
FILETIME ignore3 = {};
if (!::GetProcessTimes(::GetCurrentProcess(), &creation_time, &ignore1,
&ignore2, &ignore3)) {
return Time();

}
return Time::FromFileTime(creation_time);
}

Expand All @@ -36,7 +38,7 @@ IntegrityLevel GetCurrentProcessIntegrityLevel() {
win::ScopedHandle scoped_process_token(process_token);

DWORD token_info_length = 0;
if (::GetTokenInformation(process_token, TokenIntegrityLevel, NULL, 0,
if (::GetTokenInformation(process_token, TokenIntegrityLevel, nullptr, 0,
&token_info_length) ||
::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
return INTEGRITY_UNKNOWN;
Expand All @@ -58,7 +60,8 @@ IntegrityLevel GetCurrentProcessIntegrityLevel() {

DWORD integrity_level = *::GetSidSubAuthority(
token_label->Label.Sid,
static_cast<DWORD>(*::GetSidSubAuthorityCount(token_label->Label.Sid)-1));
static_cast<DWORD>(*::GetSidSubAuthorityCount(token_label->Label.Sid) -
1));

if (integrity_level < SECURITY_MANDATORY_MEDIUM_RID)
return LOW_INTEGRITY;
Expand Down

0 comments on commit fd1c593

Please sign in to comment.