From: Stefan Fritsch Date: Sun, 18 Dec 2011 17:38:24 +0000 (+0000) Subject: Avoid segfault if url->hostname is NULL and filter->hostname is "*" or ".". X-Git-Tag: 2.5.0-alpha~7659 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=42c9e0b3936fbc1daa0e935aa0f95d32a0c42985;p=apache Avoid segfault if url->hostname is NULL and filter->hostname is "*" or ".". Found by clang. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1220467 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/cache/cache_util.c b/modules/cache/cache_util.c index 4b19d1ed4b..bad438aca2 100644 --- a/modules/cache/cache_util.c +++ b/modules/cache/cache_util.c @@ -72,8 +72,10 @@ static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen, const size_t fhostlen = strlen(filter->hostname); const size_t uhostlen = url->hostname ? strlen(url->hostname) : 0; - if (fhostlen > uhostlen || strcasecmp(filter->hostname, - url->hostname + uhostlen - fhostlen)) { + if (fhostlen > uhostlen + || (url->hostname + && strcasecmp(filter->hostname, + url->hostname + uhostlen - fhostlen))) { return 0; } } @@ -81,8 +83,10 @@ static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen, const size_t fhostlen = strlen(filter->hostname + 1); const size_t uhostlen = url->hostname ? strlen(url->hostname) : 0; - if (fhostlen > uhostlen || strcasecmp(filter->hostname + 1, - url->hostname + uhostlen - fhostlen)) { + if (fhostlen > uhostlen + || (url->hostname + && strcasecmp(filter->hostname + 1, + url->hostname + uhostlen - fhostlen))) { return 0; } }