Chromium Code Reviews| Index: blimp/net/compressed_packet_unittest.cc |
| diff --git a/blimp/net/compressed_packet_unittest.cc b/blimp/net/compressed_packet_unittest.cc |
| index 61e39b88bb8779645626e61e92ee60387937f4bc..d462689544632ad4a86e7208e065d89c2ab81183 100644 |
| --- a/blimp/net/compressed_packet_unittest.cc |
| +++ b/blimp/net/compressed_packet_unittest.cc |
| @@ -2,6 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <stdlib.h> |
| + |
| #include "base/memory/ptr_util.h" |
| #include "base/sys_byteorder.h" |
| #include "blimp/net/common.h" |
| @@ -153,6 +155,26 @@ TEST_F(CompressedPacketTest, LargeInput) { |
| EXPECT_TRUE(CheckRoundTrip(big_str)); |
| } |
| +TEST_F(CompressedPacketTest, LowCompressionRatio) { |
| + // This size (2338) was found "in the wild" to repro an issue with output |
| + // buffer overflows. |
| + std::vector<uint8_t> source_data(2338); |
| + unsigned int rand_seed = 0; |
| + |
| + // Write two incompressible (high entropy) blocks. |
|
Wez
2016/04/13 01:11:02
nit: Why two?
|
| + for (size_t i = 0; i < source_data.size(); ++i) { |
| + source_data[i] = rand_r(&rand_seed); |
| + } |
| + EXPECT_TRUE( |
| + CheckRoundTrip(std::string(source_data.begin(), source_data.end()))); |
| + |
| + for (size_t i = 0; i < source_data.size(); ++i) { |
| + source_data[i] = rand_r(&rand_seed); |
| + } |
| + EXPECT_TRUE( |
| + CheckRoundTrip(std::string(source_data.begin(), source_data.end()))); |
| +} |
| + |
| TEST_F(CompressedPacketTest, DecompressIllegallyLargePayload) { |
| // We can't use the compressor to compress an illegally sized payload, however |
| // we can concatenate the output of smaller payloads to form an uber-payload. |