Bug 26237

Summary: Apache 1.3.19 segfaulting in ap_get_local_host
Product: Ports & Packages Reporter: Scot W. Hetzel <hetzels>
Component: Individual Port(s)Assignee: Andrey A. Chernov <ache>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Scot W. Hetzel 2001-03-31 02:50:00 UTC
Apache Segfaults in ap_get_local_host when ServerName directive is not defined
in httpd.conf.

Fix: 

place the following patch as files/patch-util.c in the apache13, apache13+ipv6,
and apache13-modssl ports. apache13-fp is not affected as a similar patch was
added a week ago. apache13-ssl < 1.3.19.

This patch was obtained from the Apache cvsweb site:

http://www.apache.org/websrc/viewcvs.cgi/apache-1.3/src/main/util.c.diff?r1=text&tr1=1.194&r2=text&tr2=1.197&diff_format=u

NOTE: Could one of the commiters add this patch before 4.3-RELEASE
 I have informed the other Apache13* maintainers on this problem,
 and will inform them of this PR also.

--- src/main/util.c	2001/02/01 10:06:37	1.194
+++ src/main/util.c	2001/03/30 17:37:54	1.197
@@ -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);
 }
@@ -2040,7 +2042,6 @@
 	ap_log_error(APLOG_MARK, APLOG_WARNING, NULL,
 	             "%s: gethostname() failed to determine ServerName\n",
                      ap_server_argv0);
-	server_hostname = ap_pstrdup(a, "127.0.0.1");
     }
     else 
     {
@@ -2048,14 +2049,14 @@
         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 && 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 */
             }
         }
 	else
-            /* Since we found a fdqn, return it with no logged message. */
+            /* Since we found a fqdn, return it with no logged message. */
             return server_hostname;
     }
How-To-Repeat: 
Install apache13, apache13+ipv6, or apache13-modssl and remove the ServerName
directive from httpd.conf.
Comment 1 Doug Barton freebsd_committer freebsd_triage 2001-04-25 09:28:18 UTC
Responsible Changed
From-To: freebsd-ports->ache


Over to maintainer.
Comment 2 dwcjr 2001-06-25 05:14:07 UTC
Does this still happen in 1.3.20?
Comment 3 dwcjr freebsd_committer freebsd_triage 2001-07-23 03:58:47 UTC
State Changed
From-To: open->closed

Timed out from originator (1 month)