* gcc-gethostbyaddr memory leak
@ 1999-12-09 15:37 Andrew Wallace
1999-12-09 18:14 ` Arthur Gold
1999-12-31 22:24 ` Andrew Wallace
0 siblings, 2 replies; 4+ messages in thread
From: Andrew Wallace @ 1999-12-09 15:37 UTC (permalink / raw)
To: help-gcc
I hope this is the correct list, this looks like a gcc problem. I don't think
it's a programming question.
The following code leaks when it is passed an address that it cannot find. If
anybody has any suggestions I would appreciate any help.
Thanks,
Andrew
System info:
gcc version 2.95.1 19990816
Linux Redhat v6.0, I'm sorry I can't find the kernel version
// simple program to demo the leak in gethostbyaddr when a
// name is not found
#include <netdb.h>
#include <sys/socket.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
char* GetAddrName(char* clean_address)
{
static int init_state;
struct in_addr ip;
if (inet_aton(clean_address, &ip))
{
struct hostent* hostinfo = gethostbyaddr((char*)&ip, sizeof(ip), AF_INET);
if (hostinfo)
return hostinfo->h_name;
if (h_errno != 1) // display anything but HOST NOT FOUND
printf("ERROR: gethostbyaddr (%s,%d)(%s,%d)(%s)\n",
hstrerror(h_errno), h_errno, strerror(errno), errno, clean_address);
} // if
else
printf("ERROR: address seems invalid: %s\n", clean_address);
return NULL;
}
int main(int argc, char** argv)
{
int x;
char buff[124];
for (x = 0; x < 50000; x++)
{
sprintf(buff,"%d.%d.%d.%d",210,10,3, (random()%254) + 1);
printf("%-20.20s %s\n", GetAddrName(buff), buff);
if (!(x % 100))
sleep(1);
}
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gcc-gethostbyaddr memory leak
1999-12-09 15:37 gcc-gethostbyaddr memory leak Andrew Wallace
@ 1999-12-09 18:14 ` Arthur Gold
1999-12-31 22:24 ` Arthur Gold
1999-12-31 22:24 ` Andrew Wallace
1 sibling, 1 reply; 4+ messages in thread
From: Arthur Gold @ 1999-12-09 18:14 UTC (permalink / raw)
To: help-gcc
Andrew Wallace wrote:
>
> I hope this is the correct list, this looks like a gcc problem. I don't think
> it's a programming question.
Actually, IIRC it's a glibc problem...tht I think is fixed in 2.1.2.
HTH,
--ag
>
> The following code leaks when it is passed an address that it cannot find. If
> anybody has any suggestions I would appreciate any help.
>
> Thanks,
>
> Andrew
>
> System info:
> gcc version 2.95.1 19990816
> Linux Redhat v6.0, I'm sorry I can't find the kernel version
>
> // simple program to demo the leak in gethostbyaddr when a
> // name is not found
>
> #include <netdb.h>
> #include <sys/socket.h>
> #include <errno.h>
> #include <netinet/in.h>
> #include <arpa/inet.h>
>
> char* GetAddrName(char* clean_address)
> {
> static int init_state;
> struct in_addr ip;
>
> if (inet_aton(clean_address, &ip))
> {
> struct hostent* hostinfo = gethostbyaddr((char*)&ip, sizeof(ip), AF_INET);
>
> if (hostinfo)
> return hostinfo->h_name;
>
> if (h_errno != 1) // display anything but HOST NOT FOUND
> printf("ERROR: gethostbyaddr (%s,%d)(%s,%d)(%s)\n",
> hstrerror(h_errno), h_errno, strerror(errno), errno, clean_address);
>
> } // if
>
> else
> printf("ERROR: address seems invalid: %s\n", clean_address);
>
> return NULL;
> }
>
> int main(int argc, char** argv)
> {
> int x;
> char buff[124];
>
> for (x = 0; x < 50000; x++)
> {
> sprintf(buff,"%d.%d.%d.%d",210,10,3, (random()%254) + 1);
>
> printf("%-20.20s %s\n", GetAddrName(buff), buff);
> if (!(x % 100))
> sleep(1);
> }
> }
--
Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info)
mailto:agold@bga.com or mailto:agold@cs.utexas.edu
--
A: Look for a lawyer who speaks Aramaic...about trademark infringement.
^ permalink raw reply [flat|nested] 4+ messages in thread
* gcc-gethostbyaddr memory leak
1999-12-09 15:37 gcc-gethostbyaddr memory leak Andrew Wallace
1999-12-09 18:14 ` Arthur Gold
@ 1999-12-31 22:24 ` Andrew Wallace
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Wallace @ 1999-12-31 22:24 UTC (permalink / raw)
To: help-gcc
I hope this is the correct list, this looks like a gcc problem. I don't think
it's a programming question.
The following code leaks when it is passed an address that it cannot find. If
anybody has any suggestions I would appreciate any help.
Thanks,
Andrew
System info:
gcc version 2.95.1 19990816
Linux Redhat v6.0, I'm sorry I can't find the kernel version
// simple program to demo the leak in gethostbyaddr when a
// name is not found
#include <netdb.h>
#include <sys/socket.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
char* GetAddrName(char* clean_address)
{
static int init_state;
struct in_addr ip;
if (inet_aton(clean_address, &ip))
{
struct hostent* hostinfo = gethostbyaddr((char*)&ip, sizeof(ip), AF_INET);
if (hostinfo)
return hostinfo->h_name;
if (h_errno != 1) // display anything but HOST NOT FOUND
printf("ERROR: gethostbyaddr (%s,%d)(%s,%d)(%s)\n",
hstrerror(h_errno), h_errno, strerror(errno), errno, clean_address);
} // if
else
printf("ERROR: address seems invalid: %s\n", clean_address);
return NULL;
}
int main(int argc, char** argv)
{
int x;
char buff[124];
for (x = 0; x < 50000; x++)
{
sprintf(buff,"%d.%d.%d.%d",210,10,3, (random()%254) + 1);
printf("%-20.20s %s\n", GetAddrName(buff), buff);
if (!(x % 100))
sleep(1);
}
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gcc-gethostbyaddr memory leak
1999-12-09 18:14 ` Arthur Gold
@ 1999-12-31 22:24 ` Arthur Gold
0 siblings, 0 replies; 4+ messages in thread
From: Arthur Gold @ 1999-12-31 22:24 UTC (permalink / raw)
To: help-gcc
Andrew Wallace wrote:
>
> I hope this is the correct list, this looks like a gcc problem. I don't think
> it's a programming question.
Actually, IIRC it's a glibc problem...tht I think is fixed in 2.1.2.
HTH,
--ag
>
> The following code leaks when it is passed an address that it cannot find. If
> anybody has any suggestions I would appreciate any help.
>
> Thanks,
>
> Andrew
>
> System info:
> gcc version 2.95.1 19990816
> Linux Redhat v6.0, I'm sorry I can't find the kernel version
>
> // simple program to demo the leak in gethostbyaddr when a
> // name is not found
>
> #include <netdb.h>
> #include <sys/socket.h>
> #include <errno.h>
> #include <netinet/in.h>
> #include <arpa/inet.h>
>
> char* GetAddrName(char* clean_address)
> {
> static int init_state;
> struct in_addr ip;
>
> if (inet_aton(clean_address, &ip))
> {
> struct hostent* hostinfo = gethostbyaddr((char*)&ip, sizeof(ip), AF_INET);
>
> if (hostinfo)
> return hostinfo->h_name;
>
> if (h_errno != 1) // display anything but HOST NOT FOUND
> printf("ERROR: gethostbyaddr (%s,%d)(%s,%d)(%s)\n",
> hstrerror(h_errno), h_errno, strerror(errno), errno, clean_address);
>
> } // if
>
> else
> printf("ERROR: address seems invalid: %s\n", clean_address);
>
> return NULL;
> }
>
> int main(int argc, char** argv)
> {
> int x;
> char buff[124];
>
> for (x = 0; x < 50000; x++)
> {
> sprintf(buff,"%d.%d.%d.%d",210,10,3, (random()%254) + 1);
>
> printf("%-20.20s %s\n", GetAddrName(buff), buff);
> if (!(x % 100))
> sleep(1);
> }
> }
--
Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info)
mailto:agold@bga.com or mailto:agold@cs.utexas.edu
--
A: Look for a lawyer who speaks Aramaic...about trademark infringement.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-12-31 22:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-09 15:37 gcc-gethostbyaddr memory leak Andrew Wallace
1999-12-09 18:14 ` Arthur Gold
1999-12-31 22:24 ` Arthur Gold
1999-12-31 22:24 ` Andrew Wallace
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).