summaryrefslogtreecommitdiff
path: root/resolv/res_query.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-05-07 13:05:19 -0400
committerUlrich Drepper <drepper@gmail.com>2011-05-07 13:05:19 -0400
commitf87dfb1f11c01f2ccdc40d81e134cd06b32e28e8 (patch)
treea3576051b3e8e833c4035478d4f1ac1f946f3f29 /resolv/res_query.c
parent47c3cd7a74e8c089d60d603afce6d9cf661178d6 (diff)
Backport BIND code to query name as TLD.
Diffstat (limited to 'resolv/res_query.c')
-rw-r--r--resolv/res_query.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 5ff352e2fc..26daf0d87b 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -123,7 +123,7 @@ __libc_res_nquery(res_state statp,
{
HEADER *hp = (HEADER *) answer;
int n, use_malloc = 0;
- u_int oflags = statp->_flags;
+ u_int oflags = statp->_flags;
size_t bufsize = (type == T_UNSPEC ? 2 : 1) * QUERYSIZE;
u_char *buf = alloca (bufsize);
@@ -210,7 +210,7 @@ __libc_res_nquery(res_state statp,
if (statp->options & RES_DEBUG)
printf(";; res_nquery: retry without EDNS0\n");
#endif
- goto again;
+ goto again;
}
#ifdef DEBUG
if (statp->options & RES_DEBUG)
@@ -344,6 +344,7 @@ __libc_res_nsearch(res_state statp,
int trailing_dot, ret, saved_herrno;
int got_nodata = 0, got_servfail = 0, root_on_list = 0;
int tried_as_is = 0;
+ int searched = 0;
__set_errno (0);
RES_SET_H_ERRNO(statp, HOST_NOT_FOUND); /* True if we never query. */
@@ -406,6 +407,7 @@ __libc_res_nsearch(res_state statp,
for (domain = (const char * const *)statp->dnsrch;
*domain && !done;
domain++) {
+ searched = 1;
if (domain[0][0] == '\0' ||
(domain[0][0] == '.' && domain[0][1] == '\0'))
@@ -477,11 +479,11 @@ __libc_res_nsearch(res_state statp,
}
/*
- * If the name has any dots at all, and no earlier 'as-is' query
- * for the name, and "." is not on the search list, then try an as-is
- * query now.
+ * f the query has not already been tried as is then try it
+ * unless RES_NOTLDQUERY is set and there were no dots.
*/
- if (dots && !(tried_as_is || root_on_list)) {
+ if ((dots || !searched || (statp->options & RES_NOTLDQUERY) == 0)
+ && !(tried_as_is || root_on_list)) {
ret = __libc_res_nquerydomain(statp, name, NULL, class, type,
answer, anslen, answerp,
answerp2, nanswerp2, resplen2);