Bug 49956 - gethostbyaddr leaking handles when it can't resolve address
gethostbyaddr leaking handles when it can't resolve address
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2001-07-25 12:55 EDT by Need Real Name
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-08-03 12:50:22 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2001-07-25 12:55:07 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

Description of problem:
gethostbyaddr leaks a file handle when it cannot look up the address in 
the /etc/hosts file. Placing the ip in question in the hosts file fixes 
the problem, removing it causes the problem.

char * pr_addr(unsigned int addr)
        struct hostent *hp;
        static char buf[80];

        //file handle leak occurs right here when addr not in hosts file
        hp = gethostbyaddr((char *)&addr, 4, AF_INET);

        if ( hp == NULL )
                //sprintf(buf, "%s", inet_ntoa(*(struct in_addr *)&addr));
                sprintf(buf,"pr_addr : could not resolve host.\n");
                sprintf(buf, "%s (%s)", hp->h_name,
                        inet_ntoa(*(struct in_addr *)&addr));

How reproducible:

Steps to Reproduce:
1.See sample code above.

Additional info:
Comment 1 Cristian Gafton 2001-07-25 20:59:31 EDT
Move to the right product and component
Comment 2 Jakub Jelinek 2001-08-03 12:50:16 EDT
Which exact glibc version are you using?
How does your /etc/nsswitch.conf look like (does it search dns too, or just
files, or what)?
What exact addresses are you trying (can you cook up a self contained testcase,
not just a single function)?
What does strace show up?
Comment 3 Jakub Jelinek 2001-09-06 13:31:41 EDT
Cannot reproduce this.

Note You need to log in before you can comment on or make changes to this bug.