Skip to content

ares_getaddrinfo(): do not use search domains if ARES_FLAG_NOSEARCH is set#638

Merged
bradh352 merged 3 commits intoc-ares:mainfrom
petrvh:fix-getaddrinfo-nosearch-option
Nov 27, 2023
Merged

ares_getaddrinfo(): do not use search domains if ARES_FLAG_NOSEARCH is set#638
bradh352 merged 3 commits intoc-ares:mainfrom
petrvh:fix-getaddrinfo-nosearch-option

Conversation

@petrvh
Copy link
Contributor

@petrvh petrvh commented Nov 27, 2023

c-ares init options defines a flag ARES_FLAG_NOSEARCH that is supposed to prevent search using configured domain suffixes.

however when using ares_getaddrinfo() the flag was ignored and domain suffixes were used anyway.

Unfortunately explicitly configuring zero domains to search also does not work (if ndomains == 0 default domain search list is loaded regardless of the flag ARES_OPT_DOMAINS being set).

this change adds a check for the ARES_FLAG_NOSEARCH in as_is_only() function that is used by ares_getaddrinfo() to decide if to try to query next possible name ( next_dns_lookup() )

@bradh352
Copy link
Member

bradh352 commented Nov 27, 2023

At first glance this seems to make sense. My guess is this probably broke in the 1.16 timeframe when getaddrinfo was introduced and gethostbyname was made as a wrapper around getaddrinfo, so I think getaddrinfo has never supported this.

We probably need to add an explicit test case for this.

@petrvh
Copy link
Contributor Author

petrvh commented Nov 27, 2023

I can also see that the condition in function as_is_first()

if (hquery->name != NULL && nname && hquery->name[nname - 1] == '.') {

essentially implements the logic of as_is_only() so it can be replaced by call to this function, it also makes sense as "as_is_only" should imply "as_is_first" (and only)

@petrvh
Copy link
Contributor Author

petrvh commented Nov 27, 2023

#637

@petrvh petrvh marked this pull request as ready for review November 27, 2023 14:38
@bradh352 bradh352 merged commit f1bf69c into c-ares:main Nov 27, 2023
petrvh added a commit to petrvh/c-ares that referenced this pull request Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants