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

Side by Side Diff: ipc/ipc_fuzzing_tests.cc

Issue 1331673002: ipc: Convert k(u)int*max types from basictypes.h to std::numeric_limits variants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win? Created 5 years, 3 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
« no previous file with comments | « ipc/ipc_channel.h ('k') | ipc/ipc_message.h » ('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) 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 <stdint.h> 5 #include <stdint.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 7
8 #include <limits>
8 #include <sstream> 9 #include <sstream>
9 #include <string> 10 #include <string>
10 11
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
15 #include "ipc/ipc_test_base.h" 16 #include "ipc/ipc_test_base.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
(...skipping 15 matching lines...) Expand all
33 34
34 // Used to generate an ID for a message that should not exist. 35 // Used to generate an ID for a message that should not exist.
35 IPC_MESSAGE_CONTROL0(MsgUnhandled) 36 IPC_MESSAGE_CONTROL0(MsgUnhandled)
36 37
37 // ----------------------------------------------------------------------------- 38 // -----------------------------------------------------------------------------
38 39
39 namespace { 40 namespace {
40 41
41 TEST(IPCMessageIntegrity, ReadBeyondBufferStr) { 42 TEST(IPCMessageIntegrity, ReadBeyondBufferStr) {
42 // This was BUG 984408. 43 // This was BUG 984408.
43 uint32_t v1 = kuint32max - 1; 44 uint32_t v1 = std::numeric_limits<uint32_t>::max() - 1;
44 int v2 = 666; 45 int v2 = 666;
45 IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL); 46 IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL);
46 EXPECT_TRUE(m.WriteInt(v1)); 47 EXPECT_TRUE(m.WriteInt(v1));
47 EXPECT_TRUE(m.WriteInt(v2)); 48 EXPECT_TRUE(m.WriteInt(v2));
48 49
49 base::PickleIterator iter(m); 50 base::PickleIterator iter(m);
50 std::string vs; 51 std::string vs;
51 EXPECT_FALSE(iter.ReadString(&vs)); 52 EXPECT_FALSE(iter.ReadString(&vs));
52 } 53 }
53 54
54 TEST(IPCMessageIntegrity, ReadBeyondBufferStr16) { 55 TEST(IPCMessageIntegrity, ReadBeyondBufferStr16) {
55 // This was BUG 984408. 56 // This was BUG 984408.
56 uint32_t v1 = kuint32max - 1; 57 uint32_t v1 = std::numeric_limits<uint32_t>::max() - 1;
57 int v2 = 777; 58 int v2 = 777;
58 IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL); 59 IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL);
59 EXPECT_TRUE(m.WriteInt(v1)); 60 EXPECT_TRUE(m.WriteInt(v1));
60 EXPECT_TRUE(m.WriteInt(v2)); 61 EXPECT_TRUE(m.WriteInt(v2));
61 62
62 base::PickleIterator iter(m); 63 base::PickleIterator iter(m);
63 base::string16 vs; 64 base::string16 vs;
64 EXPECT_FALSE(iter.ReadString16(&vs)); 65 EXPECT_FALSE(iter.ReadString16(&vs));
65 } 66 }
66 67
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // thrown out of sync by the extra argument. 364 // thrown out of sync by the extra argument.
364 msg = new MsgClassIS(3, base::ASCIIToUTF16("expect three")); 365 msg = new MsgClassIS(3, base::ASCIIToUTF16("expect three"));
365 sender()->Send(msg); 366 sender()->Send(msg);
366 EXPECT_TRUE(listener.ExpectMessage(3, MsgClassIS::ID)); 367 EXPECT_TRUE(listener.ExpectMessage(3, MsgClassIS::ID));
367 368
368 EXPECT_TRUE(WaitForClientShutdown()); 369 EXPECT_TRUE(WaitForClientShutdown());
369 DestroyChannel(); 370 DestroyChannel();
370 } 371 }
371 372
372 } // namespace 373 } // namespace
OLDNEW
« no previous file with comments | « ipc/ipc_channel.h ('k') | ipc/ipc_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698