summaryrefslogtreecommitdiffstats
path: root/sandbox/src/win_utils.cc
diff options
context:
space:
mode:
authorcpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-07 03:10:12 +0000
committercpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-07 03:10:12 +0000
commita7cab943cd84df541a4f290a431f39942f3934bf (patch)
treeae28a35b76b2d6676b0bcb1115ddfd8b51c03117 /sandbox/src/win_utils.cc
parentb78804c8b2abe1ea162383795e612af1a09e273f (diff)
downloadchromium_src-a7cab943cd84df541a4f290a431f39942f3934bf.zip
chromium_src-a7cab943cd84df541a4f290a431f39942f3934bf.tar.gz
chromium_src-a7cab943cd84df541a4f290a431f39942f3934bf.tar.bz2
Allow native (nt-style) paths to be used for sandbox policy specification
1- bypass fixup when adding the path into the policy 2- make SameObject() do case-insensitive perfect match BUG=50774 TEST= unit test included Review URL: http://codereview.chromium.org/3092014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55329 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/src/win_utils.cc')
-rw-r--r--sandbox/src/win_utils.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/sandbox/src/win_utils.cc b/sandbox/src/win_utils.cc
index 8be9ce4..7a95b32 100644
--- a/sandbox/src/win_utils.cc
+++ b/sandbox/src/win_utils.cc
@@ -139,7 +139,8 @@ bool SameObject(HANDLE handle, const wchar_t* full_path) {
if (path[path.length() - 1] == kBackslash)
path = path.substr(0, path.length() - 1);
- if (0 == actual_path.compare(full_path))
+ // Perfect match (case-insesitive check).
+ if (0 == _wcsicmp(actual_path.c_str(), path.c_str()))
return true;
// Look for the drive letter.
@@ -265,6 +266,17 @@ bool GetPathFromHandle(HANDLE handle, std::wstring* path) {
return true;
}
+bool GetNtPathFromWin32Path(const std::wstring& path, std::wstring* nt_path) {
+ HANDLE file = ::CreateFileW(path.c_str(), 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
+ OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (file == INVALID_HANDLE_VALUE)
+ return false;
+ bool rv = GetPathFromHandle(file, nt_path);
+ ::CloseHandle(file);
+ return rv;
+}
+
bool WriteProtectedChildMemory(HANDLE child_process, void* address,
const void* buffer, size_t length) {
// First, remove the protections.