From: Bradley Nicholes Date: Fri, 26 Apr 2002 21:55:41 +0000 (+0000) Subject: Added a check to make sure that h_aliases is not NULL before we try to X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f7c451c38d209a3c47d9597a3377ebe3831c031f;p=apache Added a check to make sure that h_aliases is not NULL before we try to dereference it in the for(...) loop. Attempting to dereference a NULL pointer was causing a fault if there were no aliases found. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94819 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/util.c b/server/util.c index 85bb370403..22a7db7d41 100644 --- a/server/util.c +++ b/server/util.c @@ -1798,12 +1798,14 @@ static char *find_fqdn(apr_pool_t *a, struct hostent *p) int x; if (!strchr(p->h_name, '.')) { - for (x = 0; p->h_aliases[x]; ++x) { - if (strchr(p->h_aliases[x], '.') && - (!strncasecmp(p->h_aliases[x], p->h_name, strlen(p->h_name)))) - return apr_pstrdup(a, p->h_aliases[x]); - } - return NULL; + if (p->h_aliases) { + for (x = 0; p->h_aliases[x]; ++x) { + if (strchr(p->h_aliases[x], '.') && + (!strncasecmp(p->h_aliases[x], p->h_name, strlen(p->h_name)))) + return apr_pstrdup(a, p->h_aliases[x]); + } + } + return NULL; } return apr_pstrdup(a, (void *) p->h_name); }