Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle empty answers as EAI_ADDRFAMILY #1324

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ghazel
Copy link
Contributor

@ghazel ghazel commented Aug 12, 2022

When dns resolution retrieves answers but not of the requested address family, it passes NULL as the answer. Then bufferevent_connect_getaddrinfo_cb crashes. This is documented here:

libevent/evdns.c

Line 5567 in 99fd68a

/* Note that we return an empty answer if we found entries for

To address this, this patch returns the error EAI_ADDRFAMILY instead.

(I'm not particularly fond of evdns returning empty answers; it's probable that the EAI_ADDRFAMILY response should be moved into evdns itself)

@azat azat self-assigned this Aug 13, 2022
@azat
Copy link
Member

azat commented Aug 13, 2022

And only for hosts file, interesting.

(I'm not particularly fond of evdns returning empty answers; it's probable that the EAI_ADDRFAMILY response should be moved into evdns itself)

Yes, let's fix the evdns itself.

@ghazel
Copy link
Contributor Author

ghazel commented Aug 14, 2022

Ok, I moved the fix to evens

@azat
Copy link
Member

azat commented Aug 15, 2022

OK. Can you please also add a unit test for this, that will show that from host entry and from real NS has the same error in this case.

/* Note that we return an empty answer if we found entries for
* this hostname but none were of the right address type. */
if (!ai) {
return EVUTIL_EAI_ADDRFAMILY;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this error does not propagated to the caller, it simply means that "OK, let's ignore entries in the /etc/hosts if they do not match"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants