[PATCH] Fix getaddrinfo
Jakub Jelinek
jakub@redhat.com
Wed Apr 23 09:58:00 GMT 2003
Hi!
https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=91234&action=view
has a testcase. If the caller manages to leave -1 on the stack in the place
which becomes herrno, then gaih_inet will eat all the stack and die.
Fixed thusly:
2003-04-23 Jakub Jelinek <jakub@redhat.com>
* sysdeps/posix/getaddrinfo.c (gaih_inet): Check for rc == ERANGE,
not rc == errno. Use extend_alloca.
--- libc/sysdeps/posix/getaddrinfo.c.jj 2002-12-20 07:36:31.000000000 -0500
+++ libc/sysdeps/posix/getaddrinfo.c 2003-04-23 05:15:51.000000000 -0400
@@ -677,13 +677,11 @@ gaih_inet (const char *name, const struc
int herrno;
struct hostent th;
size_t tmpbuflen = 512;
- char *tmpbuf;
+ char *tmpbuf = NULL;
do
{
- tmpbuflen *= 2;
- tmpbuf = __alloca (tmpbuflen);
-
+ tmpbuf = extend_alloca (tmpbuf, tmpbuflen, tmpbuflen * 2);
rc = __gethostbyaddr_r (at2->addr,
((at2->family == AF_INET6)
? sizeof(struct in6_addr)
@@ -692,7 +690,7 @@ gaih_inet (const char *name, const struc
&h, &herrno);
}
- while (rc == errno && herrno == NETDB_INTERNAL);
+ while (rc == ERANGE && herrno == NETDB_INTERNAL);
if (rc != 0 && herrno == NETDB_INTERNAL)
{
Jakub
More information about the Libc-hacker
mailing list