about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--resolv/res_query.c17
2 files changed, 20 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 650d11892d..76fda28818 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
 2014-11-21  Alexandre Oliva <aoliva@redhat.com>
 
 	[BZ #16469]
+	* resolv/res_query.c (__libc_res_nsearch): Skip leading dot in
+	search domain names.
+
+2014-11-21  Alexandre Oliva <aoliva@redhat.com>
+
+	[BZ #16469]
 	* NEWS: Update.
 	* resolv/res_query.c (__libc_res_nquerydomain): Retain
 	trailing dot.
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 33eeeb70da..4a9b3b3f27 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -413,13 +413,24 @@ __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'))
+			/* __libc_res_nquerydoman concatenates name
+			   with dname with a "." in between.  If we
+			   pass it in dname the "." we got from the
+			   configured default search path, we'll end
+			   up with "name..", which won't resolve.
+			   OTOH, passing it "" will result in "name.",
+			   which has the intended effect for both
+			   possible representations of the root
+			   domain.  */
+			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,