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

Side by Side Diff: net/quic/spdy_utils.cc

Issue 2086533002: Fix a bug in QUIC's SpdyUtils where Content-Length was being parsed as an int, not an int64, causin… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/quic/spdy_utils_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "net/quic/spdy_utils.h" 5 #include "net/quic/spdy_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return false; // Headers were invalid. 46 return false; // Headers were invalid.
47 } 47 }
48 48
49 if (ContainsKey(*headers, "content-length")) { 49 if (ContainsKey(*headers, "content-length")) {
50 // Check whether multiple values are consistent. 50 // Check whether multiple values are consistent.
51 base::StringPiece content_length_header = (*headers)["content-length"]; 51 base::StringPiece content_length_header = (*headers)["content-length"];
52 vector<string> values = 52 vector<string> values =
53 base::SplitString(content_length_header, base::StringPiece("\0", 1), 53 base::SplitString(content_length_header, base::StringPiece("\0", 1),
54 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 54 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
55 for (const string& value : values) { 55 for (const string& value : values) {
56 int new_value; 56 int64_t new_value;
57 if (!base::StringToInt(value, &new_value) || new_value < 0) { 57 if (!base::StringToInt64(value, &new_value) || new_value < 0) {
58 return false; 58 return false;
59 } 59 }
60 if (*content_length < 0) { 60 if (*content_length < 0) {
61 *content_length = new_value; 61 *content_length = new_value;
62 continue; 62 continue;
63 } 63 }
64 if (new_value != *content_length) { 64 if (new_value != *content_length) {
65 return false; 65 return false;
66 } 66 }
67 } 67 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return GURL(GetUrlFromHeaderBlock(headers)).host(); 244 return GURL(GetUrlFromHeaderBlock(headers)).host();
245 } 245 }
246 246
247 // static 247 // static
248 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { 248 bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) {
249 string url(GetUrlFromHeaderBlock(headers)); 249 string url(GetUrlFromHeaderBlock(headers));
250 return url != "" && GURL(url).is_valid(); 250 return url != "" && GURL(url).is_valid();
251 } 251 }
252 252
253 } // namespace net 253 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/spdy_utils_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698