about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2014-09-27 07:23:39 -0300
committerAlexandre Oliva <aoliva@redhat.com>2014-11-07 07:18:53 -0200
commit901aad32edcbd1cfd57ee904ada6dcc56a53b385 (patch)
tree03f8e0686d2cec76f6edb615b38be0aedda4f5c0
parentba878d017e6b65f5d2880ac8262bc68224ee3a53 (diff)
downloadglibc-901aad32edcbd1cfd57ee904ada6dcc56a53b385.tar.gz
glibc-901aad32edcbd1cfd57ee904ada6dcc56a53b385.tar.xz
glibc-901aad32edcbd1cfd57ee904ada6dcc56a53b385.zip
resolv: skip leading dot in domain to search
This should only happen if the domain to search is the root,
represented as . rather than by an empty string.  Skipping it here
prevents libc_res_nquerydomain from duplicating the trailing dot,
which would cause the domain name compression to fail.

for  ChangeLog

	PR 16469
	* resolv/res_query.c (__libc_res_nsearch): Skip leading dot in
	search domain names.
-rw-r--r--resolv/res_query.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 338ad82411..a7a45fb773 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -413,13 +413,15 @@ __libc_res_nsearch(res_state statp,
 		for (domain = (const char * const *)statp->dnsrch;
 		     *domain && !done;
 		     domain++) {
+			const char *dname = domain[0];
 			searched = 1;
 
-			if (domain[0][0] == '\0' ||
-			    (domain[0][0] == '.' && domain[0][1] == '\0'))
+			if (dname[0] == '.')
+				dname++;
+			if (dname[0] == '\0')
 				root_on_list++;
 
-			ret = __libc_res_nquerydomain(statp, name, *domain,
+			ret = __libc_res_nquerydomain(statp, name, dname,
 						      class, type,
 						      answer, anslen, answerp,
 						      answerp2, nanswerp2,