Return-Path: Delivered-To: apmail-new-httpd-archive@apache.org Received: (qmail 63785 invoked by uid 500); 29 Mar 2001 16:40:24 -0000 Mailing-List: contact new-httpd-help@apache.org; run by ezmlm Precedence: bulk Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list new-httpd@apache.org Received: (qmail 63683 invoked from network); 29 Mar 2001 16:40:23 -0000 Errors-To: Message-ID: <067f01c0b86e$d4583dc0$93c0b0d0@roweclan.net> Reply-To: "William A. Rowe, Jr." From: "William A. Rowe, Jr." To: References: Subject: Re: [PATCH](apache 1.3) ap_get_local_host() dereferencing NULLpointers... Date: Thu, 29 Mar 2001 10:35:38 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Looks good to me. +1 ----- Original Message ----- From: "Brad Nicholes" To: Sent: Wednesday, March 28, 2001 2:28 PM Subject: [PATCH](apache 1.3) ap_get_local_host() dereferencing NULLpointers... The api ap_get_local_host() along with find_fqdn() do not check to make sure that (struct hostent)p->h_aliases is a valid pointer before dereferencing it and using it in a string comparison. If this pointer is NULL, which happens on NetWare when there are no aliases in the HOSTS file for the server, Apache faults while trying to reference invalid memory. The following code changes should fix this problem on all platforms. Please let me know if there are any problems with this code change before I check it in. thanks, Brad Nicholes --- d:\tempapache\apache-1.3\src\main\util.c Thu Feb 01 10:06:37 2001 +++ d:\projects\1.3.x\src\main\util.c Wed Mar 28 20:09:09 2001 @@ -2013,12 +2013,14 @@ 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 ap_pstrdup(a, p->h_aliases[x]); - } - return NULL; + if (p->h_aliases) { + for (x = 0; p->h_aliases[x]; ++x) { + if (p->h_aliases[x] && strchr(p->h_aliases[x], '.') && + (!strncasecmp(p->h_aliases[x], p->h_name, strlen(p->h_name)))) + return ap_pstrdup(a, p->h_aliases[x]); + } + } + return NULL; } return ap_pstrdup(a, (void *) p->h_name); } @@ -2048,7 +2050,7 @@ if ((!(p = gethostbyname(str))) || (!(server_hostname = find_fqdn(a, p)))) { /* Recovery - return the default servername by IP: */ - if (p->h_addr_list[0]) { + if (p->h_addr_list && p->h_addr_list[0]) { ap_snprintf(str, sizeof(str), "%pA", p->h_addr_list[0]); server_hostname = ap_pstrdup(a, str); /* We will drop through to report the IP-named server */