public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Filter results from gethostbyname4_r according to request flags
@ 2011-06-16 14:21 Andreas Schwab
  2011-06-21 15:23 ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2011-06-16 14:21 UTC (permalink / raw)
  To: libc-hacker

2011-06-16  Andreas Schwab  <schwab@redhat.com>

	[BZ #12885]
	* sysdeps/posix/getaddrinfo.c (gaih_inet): Filter results from
	gethostbyname4_r according to request flags.
---
 sysdeps/posix/getaddrinfo.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 469abe2..1db1e26 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -889,7 +889,29 @@ gaih_inet (const char *name, const struct gaih_service *service,
 			canon = (*pat)->name;
 
 		      while (*pat != NULL)
-			pat = &((*pat)->next);
+			{
+			  if ((*pat)->family == AF_INET
+			      && req->ai_family == AF_INET6
+			      && (req->ai_flags & AI_V4MAPPED) != 0)
+			    {
+			      uint32_t *pataddr = (*pat)->addr;
+			      (*pat)->family = AF_INET6;
+			      pataddr[3] = pataddr[0];
+			      pataddr[2] = htonl (0xffff);
+			      pataddr[1] = 0;
+			      pataddr[0] = 0;
+			      pat = &(*pat)->next;
+			    }
+			  else if ((req->ai_family == AF_UNSPEC
+				    || (*pat)->family == req->ai_family))
+			    {
+			      if ((*pat)->family == AF_INET6)
+				got_ipv6 = true;
+			      pat = &(*pat)->next;
+			    }
+			  else
+			    *pat = (*pat)->next;
+			}
 		    }
 		}
 	      else
-- 
1.7.5.4

-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-22 12:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-16 14:21 [PATCH] Filter results from gethostbyname4_r according to request flags Andreas Schwab
2011-06-21 15:23 ` Andreas Schwab
2011-06-21 21:06   ` Ulrich Drepper
2011-06-22 12:58     ` Andreas Schwab

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).