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

Unified Diff: src/url_canon_ip.cc

Issue 2027007: Fix a crash in IP address checking because the boundary case for an empty or ... (Closed) Base URL: http://google-url.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 7 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 | src/url_canon_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/url_canon_ip.cc
===================================================================
--- src/url_canon_ip.cc (revision 133)
+++ src/url_canon_ip.cc (working copy)
@@ -58,11 +58,14 @@
bool DoFindIPv4Components(const CHAR* spec,
const url_parse::Component& host,
url_parse::Component components[4]) {
+ if (!host.is_nonempty())
+ return false;
+
int cur_component = 0; // Index of the component we're working on.
int cur_component_begin = host.begin; // Start of the current component.
int end = host.end();
for (int i = host.begin; /* nothing */; i++) {
- if (i == end || spec[i] == '.') {
+ if (i >= end || spec[i] == '.') {
// Found the end of the current component.
int component_len = i - cur_component_begin;
components[cur_component] =
@@ -79,7 +82,7 @@
if (component_len == 0 && (i != end || cur_component == 1))
Peter Kasting 2010/05/11 18:34:33 You should change "i != end" to "i < end" here.
return false;
- if (i == end)
+ if (i >= end)
break; // End of the input.
if (cur_component == 4) {
« no previous file with comments | « no previous file | src/url_canon_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698