From a52506a0e47cd8d1df525d00104606e14a06d7c7 Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Sun, 18 Dec 2011 18:00:14 +0000 Subject: [PATCH] Merge r1220467: 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/branches/2.4.x@1220508 13f79535-47bb-0310-9956-ffa450edef68 --- modules/cache/cache_util.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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; } } -- 2.40.0