You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Lars Hamren <ha...@sdu.se> on 2001/09/12 00:14:22 UTC

general/8321: Core dump when `hostname` is not a fqdn

>Number:         8321
>Category:       general
>Synopsis:       Core dump when `hostname` is not a fqdn
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apache
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Tue Sep 11 15:20:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     hamren@sdu.se
>Release:        1.3.19
>Organization:
apache
>Environment:
Linux RedHat 7.1, 
>Description:
Core dump when `hostname` is not a fqdn, e.g. "wooster" instead of
wooster.sdu.se.

This bug is serious only in the sense that it is difficult to
understand why apache dumps core.
>How-To-Repeat:
Set hostname to something that will cause gethostbyname to return 0.
>Fix:
Change the condition on line 2051 as indicated below. I have also rewritten the
surrounding if statement to make it a little easier to understand.


[root@wooster src]# diff -p apache_1.3.19/src/main/util.c{.org,}
*** apache_1.3.19/src/main/util.c.org   Tue Sep 11 23:46:40 2001
--- apache_1.3.19/src/main/util.c       Tue Sep 11 23:53:50 2001
*************** char *ap_get_local_host(pool *a)
*** 2045,2054 ****
      else 
      {
          str[sizeof(str) - 1] = '\0';
!         if ((!(p = gethostbyname(str))) 
!             || (!(server_hostname = find_fqdn(a, p)))) {
              /* Recovery - return the default servername by IP: */
!             if (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 */
--- 2045,2055 ----
      else 
      {
          str[sizeof(str) - 1] = '\0';
!         p               = gethostbyname(str);
!       server_hostname = p ? find_fqdn(a, p) : 0;
!         if (p == 0 || server_hostname == 0) {
              /* Recovery - return the default servername by IP: */
!             if (p && 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 */
>Release-Note:
>Audit-Trail:
>Unformatted:
 [In order for any reply to be added to the PR database, you need]
 [to include <ap...@Apache.Org> in the Cc line and make sure the]
 [subject line starts with the report component and number, with ]
 [or without any 'Re:' prefixes (such as "general/1098:" or      ]
 ["Re: general/1098:").  If the subject doesn't match this       ]
 [pattern, your message will be misfiled and ignored.  The       ]
 ["apbugs" address is not added to the Cc line of messages from  ]
 [the database automatically because of the potential for mail   ]
 [loops.  If you do not include this Cc, your reply may be ig-   ]
 [nored unless you are responding to an explicit request from a  ]
 [developer.  Reply only with text; DO NOT SEND ATTACHMENTS!     ]