Commit bfb548e8 authored by Pekka Pessi's avatar Pekka Pessi

Fixed url_cmp() crashing with invalid URLs.

darcs-hash:20060228132737-65a35-b749729707d7b69411e0581916f2fdee853d8051.gz
parent e219ab95
......@@ -262,8 +262,9 @@ int url_sanitize(url_t *u);
/** Argument list used when printing url with printf(). @HI */
#define URL_PRINT_ARGS(u) \
(u)->url_scheme ? (u)->url_scheme : "", \
(u)->url_type != url_any && (u)->url_scheme ? ":" : "", \
(u)->url_scheme ? (u)->url_scheme : "", \
(u)->url_type != url_any && (u)->url_scheme && (u)->url_scheme[0] \
? ":" : "", \
(u)->url_root && ((u)->url_host || (u)->url_user) ? "//" : "", \
(u)->url_user ? (u)->url_user : "", \
(u)->url_user && (u)->url_password ? ":" : "", \
......
......@@ -515,7 +515,8 @@ int _url_d(url_t *url, char *s)
url->url_type = url_get_type(url->url_scheme, n);
net_path = !url_type_is_opaque(url->url_type);
} else {
}
else {
url->url_type = url_unknown;
}
......@@ -1383,7 +1384,10 @@ int url_cmp(url_t const *a, url_t const *b)
}
if (a->url_type <= url_unknown &&
(rv = strcasecmp(a->url_scheme, b->url_scheme)));
((rv = !a->url_scheme - !b->url_scheme) ||
(a->url_scheme && b->url_scheme &&
(rv = strcasecmp(a->url_scheme, b->url_scheme)))))
return rv;
if (a->url_host != b->url_host &&
((rv = !a->url_host - !b->url_host) ||
......
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