Commit a387ce79 authored by ianswett's avatar ianswett Committed by Commit bot

Fix a bug in QUIC's SpdyUtils where Content-Length was being parsed as an int,...

Fix a bug in QUIC's SpdyUtils where Content-Length was being parsed as an int, not an int64, causing >4GB downloads to fail.  Not flag protected.

Merge internal change: 125208956
Fixes crbug/621295

R=rch@chromium.org
BUG=621295

Review-Url: https://codereview.chromium.org/2086533002
Cr-Commit-Position: refs/heads/master@{#400713}
parent 3f87994a
......@@ -53,8 +53,8 @@ bool SpdyUtils::ParseHeaders(const char* data,
base::SplitString(content_length_header, base::StringPiece("\0", 1),
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
for (const string& value : values) {
int new_value;
if (!base::StringToInt(value, &new_value) || new_value < 0) {
int64_t new_value;
if (!base::StringToInt64(value, &new_value) || new_value < 0) {
return false;
}
if (*content_length < 0) {
......
......@@ -25,8 +25,37 @@ TEST(SpdyUtilsTest, SerializeAndParseHeaders) {
input_headers[":pseudo1"] = "pseudo value1";
input_headers[":pseudo2"] = "pseudo value2";
input_headers["key1"] = "value1";
const int kContentLength = 1234;
input_headers["content-length"] = base::IntToString(kContentLength);
const int64_t kContentLength = 1234;
input_headers["content-length"] = base::Int64ToString(kContentLength);
input_headers["key2"] = "value2";
// Serialize the header block.
string serialized_headers =
SpdyUtils::SerializeUncompressedHeaders(input_headers);
// Take the serialized header block, and parse back into SpdyHeaderBlock.
SpdyHeaderBlock output_headers;
int64_t content_length = -1;
ASSERT_TRUE(SpdyUtils::ParseHeaders(serialized_headers.data(),
serialized_headers.size(),
&content_length, &output_headers));
// Should be back to the original headers.
EXPECT_EQ(content_length, kContentLength);
EXPECT_EQ(output_headers, input_headers);
}
TEST(SpdyUtilsTest, SerializeAndParseHeadersLargeContentLength) {
// Creates a SpdyHeaderBlock with some key->value pairs, serializes it, then
// parses the serialized output and verifies that the end result is the same
// as the headers that the test started with.
SpdyHeaderBlock input_headers;
input_headers[":pseudo1"] = "pseudo value1";
input_headers[":pseudo2"] = "pseudo value2";
input_headers["key1"] = "value1";
const int64_t kContentLength = 12345678900;
input_headers["content-length"] = base::Int64ToString(kContentLength);
input_headers["key2"] = "value2";
// Serialize the header block.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment