[PATCH] resovl: Avoid duplicate query if search list contains '.' (option 1)
Carlos Peón Costa
carlospeon@gmail.com
Thu Dec 18 11:35:56 GMT 2025
The same query is performed twice under some contidions:
* The domain name has enough dots to be queried 'as is'.
* The 'as is' response is NXDOMAIN
* The search list contains root domain '.'
e.g.: LOCALDOMAIN="." RES_OPTIONS="ndots:1" ./gethostbyname null.example.org
This is the simplest solution (IMO), but I'll send option 2 removing 'root_on_list'
var and reusing 'tried_as_is', as *I think* they both serve the same purpose.
The thing is so small and harmless that I didn't file a bug, let me know if it's
apropiate to do so.
---
resolv/res_query.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 039c25a3c3..29ae85e71b 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -433,8 +433,11 @@ __res_context_search (struct resolv_context *ctx,
domain. */
if (dname[0] == '.')
dname++;
- if (dname[0] == '\0')
+ if (dname[0] == '\0') {
root_on_list++;
+ if (tried_as_is)
+ continue;
+ }
ret = __res_context_querydomain
(ctx, name, dname, class, type,
--
2.52.0
More information about the Libc-alpha
mailing list