Skip to content

Commit 25c3f9a

Browse files
author
Stefan Fritsch
committed
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
1 parent adb246e commit 25c3f9a

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

modules/cache/cache_util.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,21 @@ static int uri_meets_conditions(const apr_uri_t *filter, const int pathlen,
7272
const size_t fhostlen = strlen(filter->hostname);
7373
const size_t uhostlen = url->hostname ? strlen(url->hostname) : 0;
7474

75-
if (fhostlen > uhostlen || strcasecmp(filter->hostname,
76-
url->hostname + uhostlen - fhostlen)) {
75+
if (fhostlen > uhostlen
76+
|| (url->hostname
77+
&& strcasecmp(filter->hostname,
78+
url->hostname + uhostlen - fhostlen))) {
7779
return 0;
7880
}
7981
}
8082
else if (filter->hostname[0] == '*') {
8183
const size_t fhostlen = strlen(filter->hostname + 1);
8284
const size_t uhostlen = url->hostname ? strlen(url->hostname) : 0;
8385

84-
if (fhostlen > uhostlen || strcasecmp(filter->hostname + 1,
85-
url->hostname + uhostlen - fhostlen)) {
86+
if (fhostlen > uhostlen
87+
|| (url->hostname
88+
&& strcasecmp(filter->hostname + 1,
89+
url->hostname + uhostlen - fhostlen))) {
8690
return 0;
8791
}
8892
}

0 commit comments

Comments
 (0)