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

Side by Side Diff: sandbox/src/process_policy_test.cc

Issue 155904: Fix FORWARD_NULL defects reported by Coverity.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Remove incorrect change Created 11 years, 5 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/src/named_pipe_policy_test.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include <memory> 6 #include <memory>
7 7
8 #include "base/scoped_handle_win.h" 8 #include "base/scoped_handle_win.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "sandbox/src/sandbox.h" 10 #include "sandbox/src/sandbox.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 namespace sandbox { 93 namespace sandbox {
94 94
95 // Tries to create the process in argv[0] using 7 different ways. 95 // Tries to create the process in argv[0] using 7 different ways.
96 // Since we also try the Ansi and Unicode version of the CreateProcess API, 96 // Since we also try the Ansi and Unicode version of the CreateProcess API,
97 // The process referenced by argv[0] will be spawned 14 times. 97 // The process referenced by argv[0] will be spawned 14 times.
98 SBOX_TESTS_COMMAND int Process_RunApp(int argc, wchar_t **argv) { 98 SBOX_TESTS_COMMAND int Process_RunApp(int argc, wchar_t **argv) {
99 if (argc != 1) { 99 if (argc != 1) {
100 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 100 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
101 } 101 }
102 if ((NULL != argv) && (NULL == argv[0])) { 102 if ((NULL == argv) || (NULL == argv[0])) {
103 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 103 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
104 } 104 }
105 std::wstring path = MakeFullPathToSystem32(argv[0]); 105 std::wstring path = MakeFullPathToSystem32(argv[0]);
106 106
107 // TEST 1: Try with the path in the app_name. 107 // TEST 1: Try with the path in the app_name.
108 int result1 = CreateProcessHelper(path, std::wstring()); 108 int result1 = CreateProcessHelper(path, std::wstring());
109 109
110 // TEST 2: Try with the path in the cmd_line. 110 // TEST 2: Try with the path in the cmd_line.
111 std::wstring cmd_line = L"\""; 111 std::wstring cmd_line = L"\"";
112 cmd_line += path; 112 cmd_line += path;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return result1; 156 return result1;
157 157
158 return SBOX_TEST_FAILED; 158 return SBOX_TEST_FAILED;
159 } 159 }
160 160
161 // Creates a process and checks if it's possible to get a handle to it's token. 161 // Creates a process and checks if it's possible to get a handle to it's token.
162 SBOX_TESTS_COMMAND int Process_GetChildProcessToken(int argc, wchar_t **argv) { 162 SBOX_TESTS_COMMAND int Process_GetChildProcessToken(int argc, wchar_t **argv) {
163 if (argc != 1) 163 if (argc != 1)
164 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 164 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
165 165
166 if ((NULL != argv) && (NULL == argv[0])) 166 if ((NULL == argv) || (NULL == argv[0]))
167 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 167 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
168 168
169 std::wstring path = MakeFullPathToSystem32(argv[0]); 169 std::wstring path = MakeFullPathToSystem32(argv[0]);
170 170
171 PROCESS_INFORMATION pi = {0}; 171 PROCESS_INFORMATION pi = {0};
172 STARTUPINFOW si = {sizeof(si)}; 172 STARTUPINFOW si = {sizeof(si)};
173 173
174 if (!::CreateProcessW(path.c_str(), NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, 174 if (!::CreateProcessW(path.c_str(), NULL, NULL, NULL, FALSE, CREATE_SUSPENDED,
175 NULL, NULL, &si, &pi)) { 175 NULL, NULL, &si, &pi)) {
176 return SBOX_TEST_FAILED; 176 return SBOX_TEST_FAILED;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 ASSERT_TRUE(!exe_path.empty()); 283 ASSERT_TRUE(!exe_path.empty());
284 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS, 284 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS,
285 TargetPolicy::PROCESS_ALL_EXEC, 285 TargetPolicy::PROCESS_ALL_EXEC,
286 exe_path.c_str())); 286 exe_path.c_str()));
287 287
288 EXPECT_EQ(SBOX_TEST_SUCCEEDED, 288 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
289 runner.RunTest(L"Process_GetChildProcessToken findstr.exe")); 289 runner.RunTest(L"Process_GetChildProcessToken findstr.exe"));
290 } 290 }
291 291
292 } // namespace sandbox 292 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/src/named_pipe_policy_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698