public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "siddhesh at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug network/13760] New: [PATCH] Fix dns lookup for AF_UNSPEC when response for T_A exceeds buffer size
Date: Mon, 27 Feb 2012 05:45:00 -0000	[thread overview]
Message-ID: <bug-13760-131@http.sourceware.org/bugzilla/> (raw)

http://sourceware.org/bugzilla/show_bug.cgi?id=13760

             Bug #: 13760
           Summary: [PATCH] Fix dns lookup for AF_UNSPEC when response for
                    T_A exceeds buffer size
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: network
        AssignedTo: unassigned@sourceware.org
        ReportedBy: siddhesh@redhat.com
    Classification: Unclassified


When a dns lookup is made for a host that returns a large number of
results for A (over 28 records in my test) and a finite number for
AAAA, getaddrinfo ends up returning only the AAAA records.

I have posted a patch on libc-alpha to fix this:

http://sourceware.org/ml/libc-alpha/2012-02/msg00502.html

An example DNS zone file that should trigger this problem:

$TTL    86400 ; 24 hours could have been written as 24h or 1d
$ORIGIN foo.net.
@  1D  IN        SOA ns1.foo.net.    hostmaster.foo.net. (
                              2002022401 ; serial
                              3H ; refresh
                              15 ; retry
                              1w ; expire
                              3h ; minimum
                             )
       IN  NS     ns1.foo.net. ; in the domain
; server host definitions
ns1    IN  A      192.168.0.1  ;name server definition

; non server domain hosts
ad IN A 1.0.0.1
ad IN A 1.0.0.2
ad IN A 1.0.0.3
ad IN A 1.0.0.4
ad IN A 1.0.0.5
ad IN A 1.0.0.6
ad IN A 1.0.0.7
ad IN A 1.0.0.8
ad IN A 1.0.0.9
ad IN A 1.0.1.1
ad IN A 1.0.1.2
ad IN A 1.0.1.3
ad IN A 1.0.1.4
ad IN A 1.0.1.5
ad IN A 1.0.1.6
ad IN A 1.0.1.7
ad IN A 1.0.1.8
ad IN A 1.0.1.9
ad IN A 1.0.2.1
ad IN A 1.0.2.2
ad IN A 1.0.2.3
ad IN A 1.0.2.4
ad IN A 1.0.2.5
ad IN A 1.0.2.6
ad IN A 1.0.2.7
ad IN A 1.0.2.8
ad IN A 1.0.2.9
ad IN A 1.0.3.1
ad IN AAAA 2002:2003:dead::beef:f00d

A simple lookup program returns just the IPv6 address and not the ipv4
addresses:

#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
int main(void)
{
  struct addrinfo *result;
  struct addrinfo *res;
  int error;
  const char *domain = "ad.foo.net";
  error = getaddrinfo(domain, NULL, NULL, &result);
  if (error != 0)
    {
      fprintf(stderr, "error in getaddrinfo: %s\n", gaistrerror(error));
      return 1;
    }
  /* print the domain name */
  printf("%s:\n", domain);
  /* loop over all returned results and print the addresses */
  for (res = result; res != NULL; res = res->ainext)
    {
      void *addr;
      char address[64] = "";
      if (res->aifamily == AFINET) {
    addr = &((struct sockaddrin *)(res->aiaddr))->sinaddr;
      } else if (res->aifamily == AFINET6) {
    addr = &((struct sockaddrin6 *)(res->aiaddr))->sin6addr;
      }
      inetntop(res->aiaddr->safamily, addr, address, 64);
      printf("  %s\n", address);
    }
  freeaddrinfo(result);
  return EXITSUCCESS;
}

$ ./a.out
ad.foo.net:
  2002:2003:dead::beef:f00d
  2002:2003:dead::beef:f00d
  2002:2003:dead::beef:f00d

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


             reply	other threads:[~2012-02-27  5:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27  5:45 siddhesh at redhat dot com [this message]
2012-03-30  8:47 ` [Bug network/13760] " siddhesh at redhat dot com
2014-06-26 14:35 ` fweimer at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-13760-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).