This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC PATCH 3/4] resolv: fix issues when using IPv6 nameservers only
- From: Aurelien Jarno <aurelien at aurel32 dot net>
- To: libc-alpha at sourceware dot org
- Cc: Aurelien Jarno <aurelien at aurel32 dot net>
- Date: Wed, 4 Jun 2014 01:36:42 +0200
- Subject: [RFC PATCH 3/4] resolv: fix issues when using IPv6 nameservers only
- Authentication-results: sourceware.org; auth=none
- References: <1401838603-22101-1-git-send-email-aurelien at aurel32 dot net>
statp->nscount contains the number of servers in the statp->nsaddr_list
array, which only contains IPv4 nameservers.
When resolv.conf only contains IPv6 nameservers, statp->nscount equals
to 0, which causes the existing code to add a 127.0.0.1 entry. Change
that by checking nservall, contains the number of IPv4 + IPv6 servers
instead.
The same way __libc_res_nsend exits almost immediately when
statp->nscount considering that no nameservers are available, while
IPv6 nameservers are actually available. Change that by checking
(statp->nscount + EXT(statp).nscount6) instead.
---
resolv/res_init.c | 2 +-
resolv/res_send.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 37004ab..95564af 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -427,7 +427,7 @@ __res_vinit(res_state statp, int preinit) {
#endif
(void) fclose(fp);
}
- if (__builtin_expect(statp->nscount == 0, 0)) {
+ if (__builtin_expect(nservall == 0, 0)) {
statp->nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
statp->nsaddr.sin_family = AF_INET;
statp->nsaddr.sin_port = htons(NAMESERVER_PORT);
diff --git a/resolv/res_send.c b/resolv/res_send.c
index af42b8a..08fc037 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -347,7 +347,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
{
int gotsomewhere, terrno, try, v_circuit, resplen, ns, n;
- if (statp->nscount == 0) {
+ if ((statp->nscount + EXT(statp).nscount6) == 0) {
__set_errno (ESRCH);
return (-1);
}
--
2.0.0.rc0