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

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

Issue 430753002: Resolve registry root paths in HandleCloser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | « content/common/sandbox_win.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "sandbox/win/src/handle_closer.h" 5 #include "sandbox/win/src/handle_closer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "sandbox/win/src/interceptors.h" 10 #include "sandbox/win/src/interceptors.h"
(...skipping 21 matching lines...) Expand all
32 // Memory buffer mapped from the parent, with the list of handles. 32 // Memory buffer mapped from the parent, with the list of handles.
33 SANDBOX_INTERCEPT HandleCloserInfo* g_handles_to_close; 33 SANDBOX_INTERCEPT HandleCloserInfo* g_handles_to_close;
34 34
35 HandleCloser::HandleCloser() {} 35 HandleCloser::HandleCloser() {}
36 36
37 ResultCode HandleCloser::AddHandle(const base::char16* handle_type, 37 ResultCode HandleCloser::AddHandle(const base::char16* handle_type,
38 const base::char16* handle_name) { 38 const base::char16* handle_name) {
39 if (!handle_type) 39 if (!handle_type)
40 return SBOX_ERROR_BAD_PARAMS; 40 return SBOX_ERROR_BAD_PARAMS;
41 41
42 base::string16 resolved_name;
43 if (handle_name) {
44 resolved_name = handle_name;
45 if (handle_type == base::string16(L"Key"))
cpu_(ooo_6.6-7.5) 2014/08/13 23:18:35 can you use == L"key"; so avoids constructing a st
46 if (!ResolveRegistryName(resolved_name, &resolved_name))
47 return SBOX_ERROR_BAD_PARAMS;
48 }
49
42 HandleMap::iterator names = handles_to_close_.find(handle_type); 50 HandleMap::iterator names = handles_to_close_.find(handle_type);
43 if (names == handles_to_close_.end()) { // We have no entries for this type. 51 if (names == handles_to_close_.end()) { // We have no entries for this type.
44 std::pair<HandleMap::iterator, bool> result = handles_to_close_.insert( 52 std::pair<HandleMap::iterator, bool> result = handles_to_close_.insert(
45 HandleMap::value_type(handle_type, HandleMap::mapped_type())); 53 HandleMap::value_type(handle_type, HandleMap::mapped_type()));
46 names = result.first; 54 names = result.first;
47 if (handle_name) 55 if (handle_name)
48 names->second.insert(handle_name); 56 names->second.insert(resolved_name);
49 } else if (!handle_name) { // Now we need to close all handles of this type. 57 } else if (!handle_name) { // Now we need to close all handles of this type.
50 names->second.clear(); 58 names->second.clear();
51 } else if (!names->second.empty()) { // Add another name for this type. 59 } else if (!names->second.empty()) { // Add another name for this type.
52 names->second.insert(handle_name); 60 names->second.insert(resolved_name);
53 } // If we're already closing all handles of type then we're done. 61 } // If we're already closing all handles of type then we're done.
54 62
55 return SBOX_ALL_OK; 63 return SBOX_ALL_OK;
56 } 64 }
57 65
58 size_t HandleCloser::GetBufferSize() { 66 size_t HandleCloser::GetBufferSize() {
59 size_t bytes_total = offsetof(HandleCloserInfo, handle_entries); 67 size_t bytes_total = offsetof(HandleCloserInfo, handle_entries);
60 68
61 for (HandleMap::iterator i = handles_to_close_.begin(); 69 for (HandleMap::iterator i = handles_to_close_.begin();
62 i != handles_to_close_.end(); ++i) { 70 i != handles_to_close_.end(); ++i) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 181
174 if (NT_SUCCESS(result) && name->Buffer && name->Length) 182 if (NT_SUCCESS(result) && name->Buffer && name->Length)
175 handle_name->assign(name->Buffer, name->Length / sizeof(wchar_t)); 183 handle_name->assign(name->Buffer, name->Length / sizeof(wchar_t));
176 else 184 else
177 handle_name->clear(); 185 handle_name->clear();
178 186
179 return NT_SUCCESS(result); 187 return NT_SUCCESS(result);
180 } 188 }
181 189
182 } // namespace sandbox 190 } // namespace sandbox
OLDNEW
« no previous file with comments | « content/common/sandbox_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698