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

Side by Side Diff: url/url_canon_relative.cc

Issue 23902014: Fix OOB read when parsing protocol-relative URLs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Canonicalizer functions for working with and resolving relative URLs. 5 // Canonicalizer functions for working with and resolving relative URLs.
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "url/url_canon.h" 8 #include "url/url_canon.h"
9 #include "url/url_canon_internal.h" 9 #include "url/url_canon_internal.h"
10 #include "url/url_file.h" 10 #include "url/url_file.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 bool DoResolveRelativeHost(const char* base_url, 365 bool DoResolveRelativeHost(const char* base_url,
366 const url_parse::Parsed& base_parsed, 366 const url_parse::Parsed& base_parsed,
367 const CHAR* relative_url, 367 const CHAR* relative_url,
368 const url_parse::Component& relative_component, 368 const url_parse::Component& relative_component,
369 CharsetConverter* query_converter, 369 CharsetConverter* query_converter,
370 CanonOutput* output, 370 CanonOutput* output,
371 url_parse::Parsed* out_parsed) { 371 url_parse::Parsed* out_parsed) {
372 // Parse the relative URL, just like we would for anything following a 372 // Parse the relative URL, just like we would for anything following a
373 // scheme. 373 // scheme.
374 url_parse::Parsed relative_parsed; // Everything but the scheme is valid. 374 url_parse::Parsed relative_parsed; // Everything but the scheme is valid.
375 url_parse::ParseAfterScheme(&relative_url[relative_component.begin], 375 url_parse::ParseAfterScheme(relative_url, relative_component.end(),
376 relative_component.len, relative_component.begin, 376 relative_component.begin, &relative_parsed);
377 &relative_parsed);
378 377
379 // Now we can just use the replacement function to replace all the necessary 378 // Now we can just use the replacement function to replace all the necessary
380 // parts of the old URL with the new one. 379 // parts of the old URL with the new one.
381 Replacements<CHAR> replacements; 380 Replacements<CHAR> replacements;
382 replacements.SetUsername(relative_url, relative_parsed.username); 381 replacements.SetUsername(relative_url, relative_parsed.username);
383 replacements.SetPassword(relative_url, relative_parsed.password); 382 replacements.SetPassword(relative_url, relative_parsed.password);
384 replacements.SetHost(relative_url, relative_parsed.host); 383 replacements.SetHost(relative_url, relative_parsed.host);
385 replacements.SetPort(relative_url, relative_parsed.port); 384 replacements.SetPort(relative_url, relative_parsed.port);
386 replacements.SetPath(relative_url, relative_parsed.path); 385 replacements.SetPath(relative_url, relative_parsed.path);
387 replacements.SetQuery(relative_url, relative_parsed.query); 386 replacements.SetQuery(relative_url, relative_parsed.query);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 const url_parse::Component& relative_component, 544 const url_parse::Component& relative_component,
546 CharsetConverter* query_converter, 545 CharsetConverter* query_converter,
547 CanonOutput* output, 546 CanonOutput* output,
548 url_parse::Parsed* out_parsed) { 547 url_parse::Parsed* out_parsed) {
549 return DoResolveRelativeURL<base::char16>( 548 return DoResolveRelativeURL<base::char16>(
550 base_url, base_parsed, base_is_file, relative_url, 549 base_url, base_parsed, base_is_file, relative_url,
551 relative_component, query_converter, output, out_parsed); 550 relative_component, query_converter, output, out_parsed);
552 } 551 }
553 552
554 } // namespace url_canon 553 } // namespace url_canon
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