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

Unified Diff: blimp/net/compressed_packet_unittest.cc

Issue 1882043003: Blimp: add padding for zlib framing to buffer preallocation calculations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wez feedback Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | blimp/net/compressed_packet_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | blimp/net/compressed_packet_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698