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

Side by Side Diff: net/http/http_stream_factory.cc

Issue 1893433003: Reject port numbers that contain a leading '+' in HttpStreamFactory::ProcessAlternateProtocol(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for real 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/http/http_stream_factory.h" 5 #include "net/http/http_stream_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "net/base/host_mapping_rules.h" 12 #include "net/base/host_mapping_rules.h"
13 #include "net/base/host_port_pair.h" 13 #include "net/base/host_port_pair.h"
14 #include "net/base/parse_number.h"
14 #include "net/base/port_util.h" 15 #include "net/base/port_util.h"
15 #include "net/http/http_network_session.h" 16 #include "net/http/http_network_session.h"
16 #include "net/http/http_response_headers.h" 17 #include "net/http/http_response_headers.h"
17 #include "net/quic/quic_protocol.h" 18 #include "net/quic/quic_protocol.h"
18 #include "net/spdy/spdy_alt_svc_wire_format.h" 19 #include "net/spdy/spdy_alt_svc_wire_format.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 namespace net { 22 namespace net {
22 23
23 // WARNING: If you modify or add any static flags, you must keep them in sync 24 // WARNING: If you modify or add any static flags, you must keep them in sync
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 base::SplitStringPiece(alternate_protocol_str, ":", 162 base::SplitStringPiece(alternate_protocol_str, ":",
162 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 163 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
163 if (port_protocol_vector.size() != 2) { 164 if (port_protocol_vector.size() != 2) {
164 DVLOG(1) << kAlternateProtocolHeader 165 DVLOG(1) << kAlternateProtocolHeader
165 << " header has too many tokens: " 166 << " header has too many tokens: "
166 << alternate_protocol_str; 167 << alternate_protocol_str;
167 is_valid = false; 168 is_valid = false;
168 break; 169 break;
169 } 170 }
170 171
171 if (!base::StringToInt(port_protocol_vector[0], &port) || 172 if (!ParseInt32(port_protocol_vector[0], ParseIntFormat::NON_NEGATIVE,
173 &port) ||
172 port == 0 || !IsPortValid(port)) { 174 port == 0 || !IsPortValid(port)) {
173 DVLOG(1) << kAlternateProtocolHeader 175 DVLOG(1) << kAlternateProtocolHeader
174 << " header has unrecognizable port: " 176 << " header has unrecognizable port: "
175 << port_protocol_vector[0]; 177 << port_protocol_vector[0];
176 is_valid = false; 178 is_valid = false;
177 break; 179 break;
178 } 180 }
179 181
180 protocol = AlternateProtocolFromString(port_protocol_vector[1].as_string()); 182 protocol = AlternateProtocolFromString(port_protocol_vector[1].as_string());
181 183
(...skipping 19 matching lines...) Expand all
201 } 203 }
202 204
203 HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) { 205 HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) {
204 const HostMappingRules* mapping_rules = GetHostMappingRules(); 206 const HostMappingRules* mapping_rules = GetHostMappingRules();
205 if (mapping_rules) 207 if (mapping_rules)
206 mapping_rules->RewriteHost(&host_port_pair); 208 mapping_rules->RewriteHost(&host_port_pair);
207 return host_port_pair; 209 return host_port_pair;
208 } 210 }
209 211
210 } // namespace net 212 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698