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

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

Issue 294753003: Fix clang -Wwritable-strings warnings in the Windows sandbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « sandbox/win/src/job.cc ('k') | sandbox/win/src/policy_engine_unittest.cc » ('j') | 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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 "base/win/windows_version.h" 5 #include "base/win/windows_version.h"
6 #include "sandbox/win/src/handle_closer.h" 6 #include "sandbox/win/src/handle_closer.h"
7 #include "sandbox/win/src/sandbox.h" 7 #include "sandbox/win/src/sandbox.h"
8 #include "sandbox/win/src/sandbox_policy.h" 8 #include "sandbox/win/src/sandbox_policy.h"
9 #include "sandbox/win/src/sandbox_factory.h" 9 #include "sandbox/win/src/sandbox_factory.h"
10 #include "sandbox/win/tests/common/controller.h" 10 #include "sandbox/win/tests/common/controller.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 } 103 }
104 104
105 // This tests that path canonicalization is actually disabled if we use \\?\ 105 // This tests that path canonicalization is actually disabled if we use \\?\
106 // syntax. 106 // syntax.
107 TEST(NamedPipePolicyTest, CreatePipeCanonicalization) { 107 TEST(NamedPipePolicyTest, CreatePipeCanonicalization) {
108 // "For file I/O, the "\\?\" prefix to a path string tells the Windows APIs to 108 // "For file I/O, the "\\?\" prefix to a path string tells the Windows APIs to
109 // disable all string parsing and to send the string that follows it straight 109 // disable all string parsing and to send the string that follows it straight
110 // to the file system." 110 // to the file system."
111 // http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx 111 // http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
112 wchar_t* argv[2] = { L"\\\\?\\pipe\\test\\..\\bleh", 112 const wchar_t* argv[2] = { L"\\\\?\\pipe\\test\\..\\bleh",
113 L"\\Device\\NamedPipe\\test" }; 113 L"\\Device\\NamedPipe\\test" };
114 EXPECT_EQ(SBOX_TEST_SUCCEEDED, NamedPipe_Create(2, argv)); 114 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
115 NamedPipe_Create(2, const_cast<wchar_t**>(argv)));
115 } 116 }
116 117
117 // The same test as CreatePipe but this time using strict interceptions. 118 // The same test as CreatePipe but this time using strict interceptions.
118 TEST(NamedPipePolicyTest, CreatePipeStrictInterceptions) { 119 TEST(NamedPipePolicyTest, CreatePipeStrictInterceptions) {
119 TestRunner runner; 120 TestRunner runner;
120 runner.GetPolicy()->SetStrictInterceptions(); 121 runner.GetPolicy()->SetStrictInterceptions();
121 122
122 // TODO(nsylvain): This policy is wrong because "*" is a valid char in a 123 // TODO(nsylvain): This policy is wrong because "*" is a valid char in a
123 // namedpipe name. Here we apply it like a wildcard. http://b/893603 124 // namedpipe name. Here we apply it like a wildcard. http://b/893603
124 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_NAMED_PIPES, 125 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_NAMED_PIPES,
125 TargetPolicy::NAMEDPIPES_ALLOW_ANY, 126 TargetPolicy::NAMEDPIPES_ALLOW_ANY,
126 L"\\\\.\\pipe\\test*")); 127 L"\\\\.\\pipe\\test*"));
127 128
128 EXPECT_EQ(SBOX_TEST_SUCCEEDED, 129 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
129 runner.RunTest(L"NamedPipe_Create \\\\.\\pipe\\testbleh")); 130 runner.RunTest(L"NamedPipe_Create \\\\.\\pipe\\testbleh"));
130 131
131 // On XP, the sandbox can create a pipe without any help but it fails on 132 // On XP, the sandbox can create a pipe without any help but it fails on
132 // Vista+, this is why we do not test the "denied" case. 133 // Vista+, this is why we do not test the "denied" case.
133 if (base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_VISTA) { 134 if (base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_VISTA) {
134 EXPECT_EQ(SBOX_TEST_DENIED, 135 EXPECT_EQ(SBOX_TEST_DENIED,
135 runner.RunTest(L"NamedPipe_Create \\\\.\\pipe\\bleh")); 136 runner.RunTest(L"NamedPipe_Create \\\\.\\pipe\\bleh"));
136 } 137 }
137 } 138 }
138 139
139 } // namespace sandbox 140 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/job.cc ('k') | sandbox/win/src/policy_engine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698