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

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

Issue 3135041: Merge 56938 - Sbox IPC fix... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 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/crosscall_server.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-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2010 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "sandbox/src/crosscall_client.h" 6 #include "sandbox/src/crosscall_client.h"
7 #include "sandbox/src/crosscall_server.h" 7 #include "sandbox/src/crosscall_server.h"
8 #include "sandbox/src/sharedmem_ipc_client.h" 8 #include "sandbox/src/sharedmem_ipc_client.h"
9 #include "sandbox/src/sharedmem_ipc_server.h" 9 #include "sandbox/src/sharedmem_ipc_server.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 params_2.CopyParamIn(0, &value, sizeof(value), false, ULONG_TYPE); 325 params_2.CopyParamIn(0, &value, sizeof(value), false, ULONG_TYPE);
326 buffer = const_cast<void*>(params_2.GetBuffer()); 326 buffer = const_cast<void*>(params_2.GetBuffer());
327 327
328 EXPECT_TRUE(NULL != buffer); 328 EXPECT_TRUE(NULL != buffer);
329 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, params_2.GetSize(), 329 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, params_2.GetSize(),
330 &out_size); 330 &out_size);
331 // If the buffer is malformed the return is NULL. 331 // If the buffer is malformed the return is NULL.
332 EXPECT_TRUE(NULL == ccp); 332 EXPECT_TRUE(NULL == ccp);
333 } 333 }
334 #endif // defined(NDEBUG) 334 #endif // defined(NDEBUG)
335
336 ActualCallParams<1, 256> params_3(kTag, 1);
337 params_3.CopyParamIn(0, &value, sizeof(value), false, ULONG_TYPE);
338 buffer = const_cast<void*>(params_3.GetBuffer());
339 EXPECT_TRUE(NULL != buffer);
340
341 size_t correct_size = params_3.OverrideSize(1);
342 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, 256, &out_size);
343 EXPECT_TRUE(NULL == ccp);
344
345 // The correct_size is 8 bytes aligned.
346 params_3.OverrideSize(correct_size - 7);
347 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, 256, &out_size);
348 EXPECT_TRUE(NULL == ccp);
349
350 params_3.OverrideSize(correct_size);
351 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, 256, &out_size);
352 EXPECT_TRUE(NULL != ccp);
335 } 353 }
336 354
337 // This structure is passed to the mock server threads to simulate 355 // This structure is passed to the mock server threads to simulate
338 // the server side IPC so it has the required kernel objects. 356 // the server side IPC so it has the required kernel objects.
339 struct ServerEvents { 357 struct ServerEvents {
340 HANDLE ping; 358 HANDLE ping;
341 HANDLE pong; 359 HANDLE pong;
342 volatile LONG* state; 360 volatile LONG* state;
343 HANDLE mutex; 361 HANDLE mutex;
344 }; 362 };
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 &call_return)); 614 &call_return));
597 EXPECT_EQ(SBOX_ALL_OK, call_return.call_outcome); 615 EXPECT_EQ(SBOX_ALL_OK, call_return.call_outcome);
598 EXPECT_TRUE(bar == call_return.extended[0].handle); 616 EXPECT_TRUE(bar == call_return.extended[0].handle);
599 EXPECT_EQ(foo, call_return.extended[1].unsigned_int); 617 EXPECT_EQ(foo, call_return.extended[1].unsigned_int);
600 618
601 CloseChannelEvents(client_control); 619 CloseChannelEvents(client_control);
602 delete[] reinterpret_cast<char*>(client_control); 620 delete[] reinterpret_cast<char*>(client_control);
603 } 621 }
604 622
605 } // namespace sandbox 623 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/src/crosscall_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698