[PATCH] resolv: Avoid duplicate query if search list contains '.' (option 2)
Florian Weimer
fweimer@redhat.com
Fri Jan 9 09:29:34 GMT 2026
* Carlos Peón Costa:
> This is option 2.
>
> ---
> resolv/res_query.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/resolv/res_query.c b/resolv/res_query.c
> index 039c25a3c3..30ace9d06d 100644
> --- a/resolv/res_query.c
> +++ b/resolv/res_query.c
> @@ -354,7 +354,7 @@ __res_context_search (struct resolv_context *ctx,
> char tmp[NS_MAXDNAME];
> u_int dots;
> int trailing_dot, ret, saved_herrno;
> - int got_nodata = 0, got_servfail = 0, root_on_list = 0;
> + int got_nodata = 0, got_servfail = 0;
> int tried_as_is = 0;
> int searched = 0;
>
> @@ -433,8 +433,11 @@ __res_context_search (struct resolv_context *ctx,
> domain. */
> if (dname[0] == '.')
> dname++;
> - if (dname[0] == '\0')
> - root_on_list++;
> + if (dname[0] == '\0') {
> + if (tried_as_is)
> + continue;
> + tried_as_is++;
> + }
>
> ret = __res_context_querydomain
> (ctx, name, dname, class, type,
> @@ -506,7 +509,7 @@ __res_context_search (struct resolv_context *ctx,
> * unless RES_NOTLDQUERY is set and there were no dots.
> */
> if ((dots || !searched || (statp->options & RES_NOTLDQUERY) == 0)
> - && !(tried_as_is || root_on_list)) {
> + && !tried_as_is) {
> ret = __res_context_querydomain
> (ctx, name, NULL, class, type,
> answer, anslen, answerp, answerp2, nanswerp2,
What is the intended behavior if "." is present in the search list?
I think it would be useful to change
domain .
and
domain example.com
search .
to disable search list processing. Is this what other stub resolvers
are already doing?
Thanks,
Florian
More information about the Libc-alpha
mailing list