]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
resolv: skip leading dot in domain to search
authorAlexandre Oliva <aoliva@redhat.com>
Sat, 27 Sep 2014 10:23:39 +0000 (07:23 -0300)
committerAlexandre Oliva <aoliva@redhat.com>
Fri, 7 Nov 2014 09:18:53 +0000 (07:18 -0200)
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.

resolv/res_query.c

index 338ad82411e7cd9a4fff64884658df9ef97e1e01..a7a45fb7739428fc0e562f2c0129b760a4016ebf 100644 (file)
@@ -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,