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 "ipc/ipc_message_utils.h" | 5 #include "ipc/ipc_message_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 EXPECT_EQ(sizer.payload_size(), pickle.payload_size()); | 249 EXPECT_EQ(sizer.payload_size(), pickle.payload_size()); |
250 | 250 |
251 base::PickleIterator iter(pickle); | 251 base::PickleIterator iter(pickle); |
252 base::flat_map<std::string, int> output; | 252 base::flat_map<std::string, int> output; |
253 EXPECT_TRUE(IPC::ReadParam(&pickle, &iter, &output)); | 253 EXPECT_TRUE(IPC::ReadParam(&pickle, &iter, &output)); |
254 | 254 |
255 EXPECT_EQ(input, output); | 255 EXPECT_EQ(input, output); |
256 } | 256 } |
257 | 257 |
| 258 TEST(IPCMessageUtilsTest, InvalidPickleShouldNotCrashFlatMapDeserialization) { |
| 259 base::Pickle pickle; |
| 260 IPC::WriteParam(&pickle, INT_MAX); |
| 261 IPC::WriteParam(&pickle, 0); |
| 262 IPC::WriteParam(&pickle, 0); |
| 263 |
| 264 base::PickleIterator iter(pickle); |
| 265 base::flat_map<int, int> output; |
| 266 EXPECT_FALSE(IPC::ReadParam(&pickle, &iter, &output)); |
| 267 } |
| 268 |
| 269 TEST(IPCMessageUtilsTest, InvalidPickleShouldNotCrashMapDeserialization) { |
| 270 base::Pickle pickle; |
| 271 IPC::WriteParam(&pickle, INT_MAX); |
| 272 IPC::WriteParam(&pickle, 0); |
| 273 IPC::WriteParam(&pickle, 0); |
| 274 |
| 275 base::PickleIterator iter(pickle); |
| 276 std::map<int, int> output; |
| 277 EXPECT_FALSE(IPC::ReadParam(&pickle, &iter, &output)); |
| 278 } |
| 279 |
258 } // namespace | 280 } // namespace |
259 } // namespace IPC | 281 } // namespace IPC |
OLD | NEW |