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 <stdint.h> | 5 #include <stdint.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 EXPECT_TRUE(m.WriteInt(-1)); // This is the count of elements. | 87 EXPECT_TRUE(m.WriteInt(-1)); // This is the count of elements. |
88 EXPECT_TRUE(m.WriteInt(1)); | 88 EXPECT_TRUE(m.WriteInt(1)); |
89 EXPECT_TRUE(m.WriteInt(2)); | 89 EXPECT_TRUE(m.WriteInt(2)); |
90 EXPECT_TRUE(m.WriteInt(3)); | 90 EXPECT_TRUE(m.WriteInt(3)); |
91 | 91 |
92 std::vector<double> vec; | 92 std::vector<double> vec; |
93 base::PickleIterator iter(m); | 93 base::PickleIterator iter(m); |
94 EXPECT_FALSE(ReadParam(&m, &iter, &vec)); | 94 EXPECT_FALSE(ReadParam(&m, &iter, &vec)); |
95 } | 95 } |
96 | 96 |
97 #if defined(OS_ANDROID) | 97 TEST(IPCMessageIntegrity, ReadVectorTooLarge1) { |
98 #define MAYBE_ReadVectorTooLarge1 DISABLED_ReadVectorTooLarge1 | |
99 #else | |
100 #define MAYBE_ReadVectorTooLarge1 ReadVectorTooLarge1 | |
101 #endif | |
dcheng
2017/07/13 22:25:07
Is it confirmed that this isn't a problem for the
Hzj_jie
2017/07/14 00:25:09
Looks like I should not try to include this change
| |
102 TEST(IPCMessageIntegrity, MAYBE_ReadVectorTooLarge1) { | |
103 // This was BUG 1006367. This is the large but positive length case. Again | 98 // This was BUG 1006367. This is the large but positive length case. Again |
104 // we try to hit the non-specialized case vector<P>. | 99 // we try to hit the non-specialized case vector<P>. |
105 IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL); | 100 IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL); |
106 EXPECT_TRUE(m.WriteInt(0x21000003)); // This is the count of elements. | 101 EXPECT_TRUE(m.WriteInt(0x21000003)); // This is the count of elements. |
107 EXPECT_TRUE(m.WriteInt64(1)); | 102 EXPECT_TRUE(m.WriteInt64(1)); |
108 EXPECT_TRUE(m.WriteInt64(2)); | 103 EXPECT_TRUE(m.WriteInt64(2)); |
109 | 104 |
110 std::vector<int64_t> vec; | 105 std::vector<int64_t> vec; |
111 base::PickleIterator iter(m); | 106 base::PickleIterator iter(m); |
112 EXPECT_FALSE(ReadParam(&m, &iter, &vec)); | 107 EXPECT_FALSE(ReadParam(&m, &iter, &vec)); |
113 } | 108 } |
114 | 109 |
115 TEST(IPCMessageIntegrity, ReadVectorTooLarge2) { | 110 TEST(IPCMessageIntegrity, ReadVectorTooLarge2) { |
116 // This was BUG 1006367. This is the large but positive with an additional | 111 // This was BUG 1006367. This is the large but positive with an additional |
117 // integer overflow when computing the actual byte size. Again we try to hit | 112 // integer overflow when computing the actual byte size. Again we try to hit |
118 // the non-specialized case vector<P>. | 113 // the non-specialized case vector<P>. |
119 IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL); | 114 IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL); |
120 EXPECT_TRUE(m.WriteInt(0x71000000)); // This is the count of elements. | 115 EXPECT_TRUE(m.WriteInt(0x71000000)); // This is the count of elements. |
121 EXPECT_TRUE(m.WriteInt64(1)); | 116 EXPECT_TRUE(m.WriteInt64(1)); |
122 EXPECT_TRUE(m.WriteInt64(2)); | 117 EXPECT_TRUE(m.WriteInt64(2)); |
123 | 118 |
124 std::vector<int64_t> vec; | 119 std::vector<int64_t> vec; |
125 base::PickleIterator iter(m); | 120 base::PickleIterator iter(m); |
126 EXPECT_FALSE(ReadParam(&m, &iter, &vec)); | 121 EXPECT_FALSE(ReadParam(&m, &iter, &vec)); |
127 } | 122 } |
128 | 123 |
124 // This test needs ~20 seconds in Debug mode, or ~4 seconds in Release mode. | |
125 // See http://crbug.com/741866 for details. | |
126 TEST(IPCMessageIntegrity, DISABLE_ReadVectorTooLarge3) { | |
dcheng
2017/07/13 22:25:07
Nit: DISABLED
Hzj_jie
2017/07/14 00:25:09
Done.
| |
127 base::Pickle pickle; | |
128 IPC::WriteParam(&pickle, 256 * 1024 * 1024); | |
129 IPC::WriteParam(&pickle, 0); | |
130 IPC::WriteParam(&pickle, 1); | |
131 IPC::WriteParam(&pickle, 2); | |
132 | |
133 base::PickleIterator iter(pickle); | |
134 std::vector<int> vec; | |
135 EXPECT_FALSE(IPC::ReadParam(&pickle, &iter, &vec)); | |
136 } | |
137 | |
129 class SimpleListener : public IPC::Listener { | 138 class SimpleListener : public IPC::Listener { |
130 public: | 139 public: |
131 SimpleListener() : other_(NULL) { | 140 SimpleListener() : other_(NULL) { |
132 } | 141 } |
133 void Init(IPC::Sender* s) { | 142 void Init(IPC::Sender* s) { |
134 other_ = s; | 143 other_ = s; |
135 } | 144 } |
136 protected: | 145 protected: |
137 IPC::Sender* other_; | 146 IPC::Sender* other_; |
138 }; | 147 }; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 // thrown out of sync by the extra argument. | 351 // thrown out of sync by the extra argument. |
343 msg = new MsgClassIS(3, base::ASCIIToUTF16("expect three")); | 352 msg = new MsgClassIS(3, base::ASCIIToUTF16("expect three")); |
344 sender()->Send(msg); | 353 sender()->Send(msg); |
345 EXPECT_TRUE(listener.ExpectMessage(3, MsgClassIS::ID)); | 354 EXPECT_TRUE(listener.ExpectMessage(3, MsgClassIS::ID)); |
346 | 355 |
347 EXPECT_TRUE(WaitForClientShutdown()); | 356 EXPECT_TRUE(WaitForClientShutdown()); |
348 DestroyChannel(); | 357 DestroyChannel(); |
349 } | 358 } |
350 | 359 |
351 } // namespace | 360 } // namespace |
OLD | NEW |