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

Side by Side Diff: sandbox/tests/common/controller.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "sandbox/tests/common/controller.h" 5 #include "sandbox/tests/common/controller.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/sys_string_conversions.h"
9 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
10 #include "sandbox/src/sandbox_factory.h" 11 #include "sandbox/src/sandbox_factory.h"
11 #include "sandbox/src/sandbox_utils.h" 12 #include "sandbox/src/sandbox_utils.h"
12 13
13 namespace { 14 namespace {
14 15
15 static const int kDefaultTimeout = 3000; 16 static const int kDefaultTimeout = 3000;
16 17
17 // Constructs a full path to a file inside the system32 folder. 18 // Constructs a full path to a file inside the system32 folder.
18 std::wstring MakePathToSys32(const wchar_t* name, bool is_obj_man_path) { 19 std::wstring MakePathToSys32(const wchar_t* name, bool is_obj_man_path) {
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if ((state <= MIN_STATE) || (state >= MAX_STATE)) 255 if ((state <= MIN_STATE) || (state >= MAX_STATE))
255 return SBOX_TEST_INVALID_PARAMETER; 256 return SBOX_TEST_INVALID_PARAMETER;
256 257
257 HMODULE module; 258 HMODULE module;
258 if (!GetModuleHandleHelper(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | 259 if (!GetModuleHandleHelper(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
259 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, 260 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
260 reinterpret_cast<wchar_t*>(&DispatchCall), 261 reinterpret_cast<wchar_t*>(&DispatchCall),
261 &module)) 262 &module))
262 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 263 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
263 264
264 std::string command_name = WideToMultiByte(argv[3]); 265 std::string command_name = base::SysWideToMultiByte(argv[3], CP_UTF8);
265 CommandFunction command = reinterpret_cast<CommandFunction>( 266 CommandFunction command = reinterpret_cast<CommandFunction>(
266 ::GetProcAddress(module, command_name.c_str())); 267 ::GetProcAddress(module, command_name.c_str()));
267 if (!command) 268 if (!command)
268 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 269 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
269 270
270 if (BEFORE_INIT == state) 271 if (BEFORE_INIT == state)
271 return command(argc - 4, argv + 4); 272 return command(argc - 4, argv + 4);
272 else if (EVERY_STATE == state) 273 else if (EVERY_STATE == state)
273 command(argc - 4, argv + 4); 274 command(argc - 4, argv + 4);
274 275
275 TargetServices* target = SandboxFactory::GetTargetServices(); 276 TargetServices* target = SandboxFactory::GetTargetServices();
276 if (!target) 277 if (!target)
277 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 278 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
278 279
279 if (SBOX_ALL_OK != target->Init()) 280 if (SBOX_ALL_OK != target->Init())
280 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 281 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
281 282
282 if (BEFORE_REVERT == state) 283 if (BEFORE_REVERT == state)
283 return command(argc - 4, argv + 4); 284 return command(argc - 4, argv + 4);
284 else if (EVERY_STATE == state) 285 else if (EVERY_STATE == state)
285 command(argc - 4, argv + 4); 286 command(argc - 4, argv + 4);
286 287
287 target->LowerToken(); 288 target->LowerToken();
288 return command(argc - 4, argv + 4); 289 return command(argc - 4, argv + 4);
289 } 290 }
290 291
291 } // namespace sandbox 292 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698