You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2011/12/18 18:38:25 UTC

svn commit: r1220467 - /httpd/httpd/trunk/modules/cache/cache_util.c

Author: sf
Date: Sun Dec 18 17:38:24 2011
New Revision: 1220467

URL: http://svn.apache.org/viewvc?rev=1220467&view=rev
Log:
Avoid segfault if url->hostname is NULL and filter->hostname is "*" or ".".
Found by clang.

Modified:
    httpd/httpd/trunk/modules/cache/cache_util.c

Modified: httpd/httpd/trunk/modules/cache/cache_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_util.c?rev=1220467&r1=1220466&r2=1220467&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/cache_util.c (original)
+++ httpd/httpd/trunk/modules/cache/cache_util.c Sun Dec 18 17:38:24 2011
@@ -72,8 +72,10 @@ static int uri_meets_conditions(const ap
                 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 ap
                 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;
                 }
             }