[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-bugdb
Subject:    general/6464: Server will segfault if gethostbyname fails
From:       Mike Ireton <mike () libritas ! com>
Date:       2000-08-25 3:08:10
[Download RAW message or body]


>Number:         6464
>Category:       general
>Synopsis:       Server will segfault if gethostbyname fails
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Thu Aug 24 20:10:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     mike@libritas.com
>Release:        1.3.12
>Organization:
apache
>Environment:
RedHat 5.2, Linux 2.0.38
Linux xxxx.xxxx.xxxx.xxxx 2.0.38 #1 Fri Aug 18 15:54:31 PDT 2000 i686 unknown
>Description:
Apache will segfault if, under abnormal conditions, the call to gethostname returns a name
that gethostbyname can't resolve. This leads into a condition where find_fqdn is passed a
null pointer which it happilly dereferences without checking. This code occures
is util.c, around line 1920:

    if ((!(p = gethostbyname(str))) || (!(server_hostname = find_fqdn(a, p))))
  	fprintf(stderr, "%s: cannot determine local host name.\n",

	if gethostbyname fails, it returns NULL, which then goes to p. But find_fqdn is evaluated 
regardless of wether or not gethostbyname fails, and if p is null, then this code
is flatly wrong:


static char *find_fqdn(pool *a, struct hostent *p)
{
    int x;
    if (!strchr(p->h_name, '.')) {

	The strchr will go on aimlessly thru junk.
>How-To-Repeat:
I don't know how to repeat this condition. I belive it's caused by a
presently unidentified libc issue, as under heavy debugging this would 
appear and disappear seemingly at random, and NEVER when apache was compiled
with -ggdb! The symptoms were several nameserver statements in /etc/resolv.conf
- removing all but one (127.0.0.1) made the problem go away. 
>Fix:
Patch find_fqdn to check it's hostent pointer for 
null and simply return null in that case. 
>Release-Note:
>Audit-Trail:
>Unformatted:
 [In order for any reply to be added to the PR database, you need]
 [to include <apbugs@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!     ]
 
 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic