Commit 25c3f9a7 authored by Stefan Fritsch's avatar Stefan Fritsch
Browse files

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
parent adb246e7
Loading
Loading
Loading
Loading
+8 −4
Changes for modules/cache/cache_util.c: 8 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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;
                }
            }