Skip to content

Commit

Permalink
BZ#16469: resolv: skip leading dot in domain to search
Browse files Browse the repository at this point in the history
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

	[BZ #16469]
	* resolv/res_query.c (__libc_res_nsearch): Skip leading dot in
	search domain names.
  • Loading branch information
Alexandre Oliva committed Nov 21, 2014
1 parent f3d945d commit b59d114
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
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]
Expand Down
17 changes: 14 additions & 3 deletions resolv/res_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b59d114

Please sign in to comment.