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

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

Issue 432543005: Replace NT prefix in sandbox rules match string to handle correct wildcard escaping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing include statement 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
« no previous file with comments | « sandbox/win/src/filesystem_policy.h ('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 <string> 5 #include <string>
6 6
7 #include "sandbox/win/src/filesystem_policy.h" 7 #include "sandbox/win/src/filesystem_policy.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/win/scoped_handle.h" 10 #include "base/win/scoped_handle.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // object manager style. 70 // object manager style.
71 if (0 != _wcsnicmp(mod_name.c_str(), kNTObjManPrefix, kNTObjManPrefixLen)) { 71 if (0 != _wcsnicmp(mod_name.c_str(), kNTObjManPrefix, kNTObjManPrefixLen)) {
72 // TODO(cpu) bug 32224: This prefix add is a hack because we don't have the 72 // TODO(cpu) bug 32224: This prefix add is a hack because we don't have the
73 // infrastructure to normalize names. In any case we need to escape the 73 // infrastructure to normalize names. In any case we need to escape the
74 // question marks. 74 // question marks.
75 if (!PreProcessName(mod_name, &mod_name)) { 75 if (!PreProcessName(mod_name, &mod_name)) {
76 // The path to be added might contain a reparse point. 76 // The path to be added might contain a reparse point.
77 NOTREACHED(); 77 NOTREACHED();
78 return false; 78 return false;
79 } 79 }
80 if (0 != mod_name.compare(0, kNTPrefixLen, kNTPrefix)) { 80
81 // TODO(nsylvain): Find a better way to do name resolution. Right now we 81 mod_name = FixNTPrefixForMatch(mod_name);
82 // take the name and we expand it. 82 name = mod_name.c_str();
83 mod_name.insert(0, L"\\/?/?\\");
84 name = mod_name.c_str();
85 }
86 } 83 }
87 84
88 EvalResult result = ASK_BROKER; 85 EvalResult result = ASK_BROKER;
89 86
90 // List of supported calls for the filesystem. 87 // List of supported calls for the filesystem.
91 const unsigned kCallNtCreateFile = 0x1; 88 const unsigned kCallNtCreateFile = 0x1;
92 const unsigned kCallNtOpenFile = 0x2; 89 const unsigned kCallNtOpenFile = 0x2;
93 const unsigned kCallNtQueryAttributesFile = 0x4; 90 const unsigned kCallNtQueryAttributesFile = 0x4;
94 const unsigned kCallNtQueryFullAttributesFile = 0x8; 91 const unsigned kCallNtQueryFullAttributesFile = 0x8;
95 const unsigned kCallNtSetInfoRename = 0x10; 92 const unsigned kCallNtSetInfoRename = 0x10;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 ConvertToLongPath(path, new_path); 373 ConvertToLongPath(path, new_path);
377 374
378 bool reparsed = false; 375 bool reparsed = false;
379 if (ERROR_SUCCESS != IsReparsePoint(*new_path, &reparsed)) 376 if (ERROR_SUCCESS != IsReparsePoint(*new_path, &reparsed))
380 return false; 377 return false;
381 378
382 // We can't process reparsed file. 379 // We can't process reparsed file.
383 return !reparsed; 380 return !reparsed;
384 } 381 }
385 382
383 base::string16 FixNTPrefixForMatch(const base::string16& name) {
384 base::string16 mod_name = name;
385
386 // NT prefix escaped for rule matcher
387 const wchar_t kNTPrefixEscaped[] = L"\\/?/?\\";
388 const int kNTPrefixEscapedLen = arraysize(kNTPrefixEscaped) - 1;
389
390 if (0 != mod_name.compare(0, kNTPrefixLen, kNTPrefix)) {
391 if (0 != mod_name.compare(0, kNTPrefixEscapedLen, kNTPrefixEscaped)) {
392 // TODO(nsylvain): Find a better way to do name resolution. Right now we
393 // take the name and we expand it.
394 mod_name.insert(0, kNTPrefixEscaped);
395 }
396 } else {
397 // Start of name matches NT prefix, replace with escaped format
398 // Fixes bug: 334882
rvargas (doing something else) 2014/08/16 02:23:17 nit: we don't generally add bug numbers that are f
399 mod_name.replace(0, kNTPrefixLen, kNTPrefixEscaped);
400 }
401
402 return mod_name;
403 }
404
386 } // namespace sandbox 405 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/filesystem_policy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698