* [PATCH] Fix getaddrinfo
@ 2003-04-23 9:58 Jakub Jelinek
2003-04-23 17:22 ` Ulrich Drepper
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2003-04-23 9:58 UTC (permalink / raw)
To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix getaddrinfo
2003-04-23 9:58 [PATCH] Fix getaddrinfo Jakub Jelinek
@ 2003-04-23 17:22 ` Ulrich Drepper
0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Drepper @ 2003-04-23 17:22 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Roland McGrath, Glibc hackers
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Jakub Jelinek wrote:
> 2003-04-23 Jakub Jelinek <jakub@redhat.com>
>
> * sysdeps/posix/getaddrinfo.c (gaih_inet): Check for rc == ERANGE,
> not rc == errno. Use extend_alloca.
That patch is fine, I applied it. Thanks,
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+psu42ijCOnn/RHQRAj2BAKDNgRNjRLHUKxKOw5a4Mug3OCj3pACgqtK+
VCRTg5HOVVW53e3rBFUi+HM=
=a8RD
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix getaddrinfo
2001-02-01 7:44 Jakub Jelinek
@ 2001-02-02 0:13 ` Ulrich Drepper
0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Drepper @ 2001-02-02 0:13 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Glibc hackers
Jakub Jelinek <jakub@redhat.com> writes:
> Since gaih_typeproto's name is now 4byte array, not char pointer, it makes
> no sense to compare it to NULL because it is always non-NULL. We have to
> test whether it is "" string instead.
Right. Thanks for the patch.
--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Fix getaddrinfo
@ 2001-02-01 7:44 Jakub Jelinek
2001-02-02 0:13 ` Ulrich Drepper
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2001-02-01 7:44 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Glibc hackers
Hi!
Since gaih_typeproto's name is now 4byte array, not char pointer, it makes
no sense to compare it to NULL because it is always non-NULL. We have to
test whether it is "" string instead.
2001-02-01 Jakub Jelinek <jakub@redhat.com>
* sysdeps/posix/getaddrinfo.c (gaih_local, gaih_inet): Replace all
tp->name tests with tp->name[0] tests.
--- libc/sysdeps/posix/getaddrinfo.c.jj Wed Jan 31 16:35:22 2001
+++ libc/sysdeps/posix/getaddrinfo.c Thu Feb 1 17:43:42 2001
@@ -151,7 +151,7 @@ gaih_local (const char *name, const stru
{
const struct gaih_typeproto *tp = gaih_inet_typeproto + 1;
- while (tp->name != NULL
+ while (tp->name[0]
&& ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0
|| (req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
|| (req->ai_protocol != 0
@@ -159,7 +159,7 @@ gaih_local (const char *name, const stru
&& req->ai_protocol != tp->protocol)))
++tp;
- if (tp->name == NULL)
+ if (! tp->name[0])
{
if (req->ai_socktype)
return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
@@ -324,14 +324,14 @@ gaih_inet (const char *name, const struc
{
++tp;
- while (tp->name != NULL
+ while (tp->name[0]
&& ((req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
|| (req->ai_protocol != 0
&& !(tp->protoflag & GAI_PROTO_PROTOANY)
&& req->ai_protocol != tp->protocol)))
++tp;
- if (tp->name == NULL)
+ if (! tp->name[0])
{
if (req->ai_socktype)
return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
@@ -347,7 +347,7 @@ gaih_inet (const char *name, const struc
if (service->num < 0)
{
- if (tp->name != NULL)
+ if (tp->name[0])
{
st = (struct gaih_servtuple *)
__alloca (sizeof (struct gaih_servtuple));
@@ -358,7 +358,7 @@ gaih_inet (const char *name, const struc
else
{
struct gaih_servtuple **pst = &st;
- for (tp++; tp->name; tp++)
+ for (tp++; tp->name[0]; tp++)
{
struct gaih_servtuple *newp;
@@ -414,7 +414,7 @@ gaih_inet (const char *name, const struc
/* Neither socket type nor protocol is set. Return all socket types
we know about. */
struct gaih_servtuple **lastp = &st;
- for (++tp; tp->name != NULL; ++tp)
+ for (++tp; tp->name[0]; ++tp)
{
struct gaih_servtuple *newp;
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-04-23 17:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-23 9:58 [PATCH] Fix getaddrinfo Jakub Jelinek
2003-04-23 17:22 ` Ulrich Drepper
-- strict thread matches above, loose matches on Subject: below --
2001-02-01 7:44 Jakub Jelinek
2001-02-02 0:13 ` Ulrich Drepper
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).