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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/win/src/filesystem_policy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/win/src/filesystem_policy.cc
diff --git a/sandbox/win/src/filesystem_policy.cc b/sandbox/win/src/filesystem_policy.cc
index 331b9fbe27916d0ad4a36d47cce8769481ba2b8e..87340a8227b866aead19bc86d15c2747012a8f10 100644
--- a/sandbox/win/src/filesystem_policy.cc
+++ b/sandbox/win/src/filesystem_policy.cc
@@ -77,12 +77,9 @@ bool FileSystemPolicy::GenerateRules(const wchar_t* name,
NOTREACHED();
return false;
}
- if (0 != mod_name.compare(0, kNTPrefixLen, kNTPrefix)) {
- // TODO(nsylvain): Find a better way to do name resolution. Right now we
- // take the name and we expand it.
- mod_name.insert(0, L"\\/?/?\\");
- name = mod_name.c_str();
- }
+
+ mod_name = FixNTPrefixForMatch(mod_name);
+ name = mod_name.c_str();
}
EvalResult result = ASK_BROKER;
@@ -383,4 +380,26 @@ bool PreProcessName(const base::string16& path, base::string16* new_path) {
return !reparsed;
}
+base::string16 FixNTPrefixForMatch(const base::string16& name) {
+ base::string16 mod_name = name;
+
+ // NT prefix escaped for rule matcher
+ const wchar_t kNTPrefixEscaped[] = L"\\/?/?\\";
+ const int kNTPrefixEscapedLen = arraysize(kNTPrefixEscaped) - 1;
+
+ if (0 != mod_name.compare(0, kNTPrefixLen, kNTPrefix)) {
+ if (0 != mod_name.compare(0, kNTPrefixEscapedLen, kNTPrefixEscaped)) {
+ // TODO(nsylvain): Find a better way to do name resolution. Right now we
+ // take the name and we expand it.
+ mod_name.insert(0, kNTPrefixEscaped);
+ }
+ } else {
+ // Start of name matches NT prefix, replace with escaped format
+ // Fixes bug: 334882
rvargas (doing something else) 2014/08/16 02:23:17 nit: we don't generally add bug numbers that are f
+ mod_name.replace(0, kNTPrefixLen, kNTPrefixEscaped);
+ }
+
+ return mod_name;
+}
+
} // namespace sandbox
« 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