| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <limits> | 10 #include <limits> |
| 8 #include <set> | 11 #include <set> |
| 9 | 12 |
| 10 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 11 #include "ipc/attachment_broker.h" | 14 #include "ipc/attachment_broker.h" |
| 12 #include "ipc/brokerable_attachment.h" | 15 #include "ipc/brokerable_attachment.h" |
| 13 #include "ipc/ipc_channel_reader.h" | 16 #include "ipc/ipc_channel_reader.h" |
| 14 #include "ipc/placeholder_brokerable_attachment.h" | 17 #include "ipc/placeholder_brokerable_attachment.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 19 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 EXPECT_FALSE(reader.TranslateInputData( | 212 EXPECT_FALSE(reader.TranslateInputData( |
| 210 reinterpret_cast<const char*>(&header), sizeof(header))); | 213 reinterpret_cast<const char*>(&header), sizeof(header))); |
| 211 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before); | 214 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before); |
| 212 | 215 |
| 213 // Payload size is negative, overflow is detected by Pickle::PeekNext() | 216 // Payload size is negative, overflow is detected by Pickle::PeekNext() |
| 214 header.payload_size = static_cast<uint32_t>(-1); | 217 header.payload_size = static_cast<uint32_t>(-1); |
| 215 EXPECT_FALSE(reader.TranslateInputData( | 218 EXPECT_FALSE(reader.TranslateInputData( |
| 216 reinterpret_cast<const char*>(&header), sizeof(header))); | 219 reinterpret_cast<const char*>(&header), sizeof(header))); |
| 217 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before); | 220 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before); |
| 218 | 221 |
| 219 // Payload size is maximum int32 value | 222 // Payload size is maximum int32_t value |
| 220 header.payload_size = std::numeric_limits<int32_t>::max(); | 223 header.payload_size = std::numeric_limits<int32_t>::max(); |
| 221 EXPECT_FALSE(reader.TranslateInputData( | 224 EXPECT_FALSE(reader.TranslateInputData( |
| 222 reinterpret_cast<const char*>(&header), sizeof(header))); | 225 reinterpret_cast<const char*>(&header), sizeof(header))); |
| 223 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before); | 226 EXPECT_LE(reader.input_overflow_buf_.capacity(), capacity_before); |
| 224 } | 227 } |
| 225 | 228 |
| 226 #endif // !USE_ATTACHMENT_BROKER | 229 #endif // !USE_ATTACHMENT_BROKER |
| 227 | 230 |
| 228 TEST(ChannelReaderTest, TrimBuffer) { | 231 TEST(ChannelReaderTest, TrimBuffer) { |
| 229 // ChannelReader uses std::string as a buffer, and calls reserve() | 232 // ChannelReader uses std::string as a buffer, and calls reserve() |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 EXPECT_GE(reader.input_overflow_buf_.capacity(), message2.size()); | 373 EXPECT_GE(reader.input_overflow_buf_.capacity(), message2.size()); |
| 371 #else | 374 #else |
| 372 // We couldn't determine size for the second (partial) message, and | 375 // We couldn't determine size for the second (partial) message, and |
| 373 // first message was small, so we did nothing. | 376 // first message was small, so we did nothing. |
| 374 #endif | 377 #endif |
| 375 } | 378 } |
| 376 } | 379 } |
| 377 | 380 |
| 378 } // namespace internal | 381 } // namespace internal |
| 379 } // namespace IPC | 382 } // namespace IPC |
| OLD | NEW |