]> granicus.if.org Git - apache/commitdiff
Merge r1220467:
authorStefan Fritsch <sf@apache.org>
Sun, 18 Dec 2011 18:00:14 +0000 (18:00 +0000)
committerStefan Fritsch <sf@apache.org>
Sun, 18 Dec 2011 18:00:14 +0000 (18:00 +0000)
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

index 4b19d1ed4b4a9e830d6685531e5611b5819a6c81..bad438aca2eb829877903039cef89a3afa5324ee 100644 (file)
@@ -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;
                 }
             }