Fix parsing of getai result from nscd
Commit Message
With nscd running, getaddrinfo misparses the getai result from nscd if
an IPv6-only result was requested.
Andreas.
* sysdeps/posix/getaddrinfo.c (gaih_inet): Advance address pointer
when skipping over non-matching result from nscd.
---
sysdeps/posix/getaddrinfo.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
Comments
On Wed, May 07, 2014 at 12:11:56PM +0200, Andreas Schwab wrote:
> With nscd running, getaddrinfo misparses the getai result from nscd if
> an IPv6-only result was requested.
>
> Andreas.
>
ok for me.
@@ -710,16 +710,20 @@ gaih_inet (const char *name, const struct gaih_service *service,
struct gaih_addrtuple *addrfree = addrmem;
for (int i = 0; i < air->naddrs; ++i)
{
+ socklen_t size = (air->family[i] == AF_INET
+ ? INADDRSZ : IN6ADDRSZ);
+
if (!((air->family[i] == AF_INET
&& req->ai_family == AF_INET6
&& (req->ai_flags & AI_V4MAPPED) != 0)
|| req->ai_family == AF_UNSPEC
|| air->family[i] == req->ai_family))
- /* Skip over non-matching result. */
- continue;
+ {
+ /* Skip over non-matching result. */
+ addrs += size;
+ continue;
+ }
- socklen_t size = (air->family[i] == AF_INET
- ? INADDRSZ : IN6ADDRSZ);
if (*pat == NULL)
{
*pat = addrfree++;