This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug network/13760] New: [PATCH] Fix dns lookup for AF_UNSPEC when response for T_A exceeds buffer size
- From: "siddhesh at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Mon, 27 Feb 2012 05:45:16 +0000
- Subject: [Bug network/13760] New: [PATCH] Fix dns lookup for AF_UNSPEC when response for T_A exceeds buffer size
- Auto-submitted: auto-generated
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.