| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "base/win/scoped_handle.h" | 10 #include "base/win/scoped_handle.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (argc != 1) { | 147 if (argc != 1) { |
| 148 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; | 148 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; |
| 149 } | 149 } |
| 150 if ((NULL == argv) || (NULL == argv[0])) { | 150 if ((NULL == argv) || (NULL == argv[0])) { |
| 151 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; | 151 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; |
| 152 } | 152 } |
| 153 | 153 |
| 154 // TEST 4: Try file name in the app_name and current directory sets correctly. | 154 // TEST 4: Try file name in the app_name and current directory sets correctly. |
| 155 base::string16 system32 = MakeFullPathToSystem32(L""); | 155 base::string16 system32 = MakeFullPathToSystem32(L""); |
| 156 wchar_t current_directory[MAX_PATH + 1]; | 156 wchar_t current_directory[MAX_PATH + 1]; |
| 157 int result4; | |
| 158 bool test_succeeded = false; | |
| 159 DWORD ret = ::GetCurrentDirectory(MAX_PATH, current_directory); | 157 DWORD ret = ::GetCurrentDirectory(MAX_PATH, current_directory); |
| 160 if (!ret) | 158 if (!ret) |
| 161 return SBOX_TEST_FIRST_ERROR; | 159 return SBOX_TEST_FIRST_ERROR; |
| 160 if (ret >= MAX_PATH) |
| 161 return SBOX_TEST_FAILED; |
| 162 | 162 |
| 163 if (ret < MAX_PATH) { | 163 current_directory[ret] = L'\\'; |
| 164 current_directory[ret] = L'\\'; | 164 current_directory[ret+1] = L'\0'; |
| 165 current_directory[ret+1] = L'\0'; | 165 if (!::SetCurrentDirectory(system32.c_str())) { |
| 166 if (::SetCurrentDirectory(system32.c_str())) { | 166 return SBOX_TEST_SECOND_ERROR; |
| 167 result4 = CreateProcessHelper(argv[0], base::string16()); | |
| 168 if (::SetCurrentDirectory(current_directory)) { | |
| 169 test_succeeded = true; | |
| 170 } | |
| 171 } else { | |
| 172 return SBOX_TEST_SECOND_ERROR; | |
| 173 } | |
| 174 } | 167 } |
| 175 if (!test_succeeded) | |
| 176 result4 = SBOX_TEST_FAILED; | |
| 177 | 168 |
| 178 return result4; | 169 const int result4 = CreateProcessHelper(argv[0], base::string16()); |
| 170 return ::SetCurrentDirectory(current_directory) ? result4 : SBOX_TEST_FAILED; |
| 179 } | 171 } |
| 180 | 172 |
| 181 SBOX_TESTS_COMMAND int Process_RunApp5(int argc, wchar_t **argv) { | 173 SBOX_TESTS_COMMAND int Process_RunApp5(int argc, wchar_t **argv) { |
| 182 if (argc != 1) { | 174 if (argc != 1) { |
| 183 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; | 175 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; |
| 184 } | 176 } |
| 185 if ((NULL == argv) || (NULL == argv[0])) { | 177 if ((NULL == argv) || (NULL == argv[0])) { |
| 186 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; | 178 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; |
| 187 } | 179 } |
| 188 base::string16 path = MakeFullPathToSystem32(argv[0]); | 180 base::string16 path = MakeFullPathToSystem32(argv[0]); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 ASSERT_TRUE(!exe_path.empty()); | 371 ASSERT_TRUE(!exe_path.empty()); |
| 380 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS, | 372 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS, |
| 381 TargetPolicy::PROCESS_ALL_EXEC, | 373 TargetPolicy::PROCESS_ALL_EXEC, |
| 382 exe_path.c_str())); | 374 exe_path.c_str())); |
| 383 | 375 |
| 384 EXPECT_EQ(SBOX_TEST_SUCCEEDED, | 376 EXPECT_EQ(SBOX_TEST_SUCCEEDED, |
| 385 runner.RunTest(L"Process_GetChildProcessToken findstr.exe")); | 377 runner.RunTest(L"Process_GetChildProcessToken findstr.exe")); |
| 386 } | 378 } |
| 387 | 379 |
| 388 } // namespace sandbox | 380 } // namespace sandbox |
| OLD | NEW |