Bug 49956 - gethostbyaddr leaking handles when it can't resolve address
Summary: gethostbyaddr leaking handles when it can't resolve address
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc   
(Show other bugs)
Version: 7.1
Hardware: i386 Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-07-25 16:55 UTC by Need Real Name
Modified: 2008-05-01 15:38 UTC (History)
0 users

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


Attachments (Terms of Use)

Description Need Real Name 2001-07-25 16:55:07 UTC
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");
        else
                sprintf(buf, "%s (%s)", hp->h_name,
                        inet_ntoa(*(struct in_addr *)&addr));
        return(buf);
}


How reproducible:
Always

Steps to Reproduce:
1.See sample code above.
2.
3.
	

Additional info:

Comment 1 Cristian Gafton 2001-07-26 00:59:31 UTC
Move to the right product and component

Comment 2 Jakub Jelinek 2001-08-03 16:50:16 UTC
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 17:31:41 UTC
Cannot reproduce this.


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