This is the mail archive of the
mailing list for the glibc project.
BZ#16469: resolv: skip leading dot in domain to search
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Fri, 14 Nov 2014 22:10:25 -0200
- Subject: BZ#16469: resolv: skip leading dot in domain to search
- Authentication-results: sourceware.org; auth=none
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.
No testcase for this one; we can't really exercise this in a controlled
fashion without overriding /etc/resolv.conf.
No regressions on x86_64-linux-gnu. Ok to install?
* resolv/res_query.c (__libc_res_nsearch): Skip leading dot in
search domain names.
resolv/res_query.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 338ad82..0d276b0 100644
@@ -413,13 +413,24 @@ __libc_res_nsearch(res_state statp,
for (domain = (const char * const *)statp->dnsrch;
*domain && !done;
+ const char *dname = domain;
searched = 1;
- if (domain == '\0' ||
- (domain == '.' && domain == '\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 == '.')
+ if (dname == '\0')
- ret = __libc_res_nquerydomain(statp, name, *domain,
+ ret = __libc_res_nquerydomain(statp, name, dname,
answer, anslen, answerp,
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer