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

ares_getaddrinfo() of port 0 reports ARES_ESERVICE #517

Closed
bagder opened this issue Mar 17, 2023 · 3 comments
Closed

ares_getaddrinfo() of port 0 reports ARES_ESERVICE #517

bagder opened this issue Mar 17, 2023 · 3 comments

Comments

@bagder
Copy link
Member

bagder commented Mar 17, 2023

... while using glibc's getaddrinfo() with the same port number works fine.

(I use ARES_AI_NUMERICSERV set in ai_flags)

Is there actually any good reason to refuse just using 0 as a dummy port?

bagder added a commit to curl/curl that referenced this issue Mar 17, 2023
It turns out c-ares returns an error when asked to resolve a host name with
ares_getaddrinfo using port number 0.

Reported as a c-ares bug here: c-ares/c-ares#517

The work-around is to simply use port 80 instead, as the number typically does
not make a difference and a non-zero number works for c-ares.

Fixes #10759
Reported-by: Matt Jolly
bagder added a commit to curl/curl that referenced this issue Mar 17, 2023
It turns out c-ares returns an error when asked to resolve a host name with
ares_getaddrinfo using port number 0.

Reported as a c-ares bug here: c-ares/c-ares#517

The work-around is to simply use port 80 instead, as the number typically does
not make a difference and a non-zero number works for c-ares.

Fixes #10759
Reported-by: Matt Jolly
Closes #10789
@bradh352
Copy link
Member

When you say zero, are you passing 0 (aka NULL) as the "service" argument, or are you passing the string "0"?

@bagder
Copy link
Member Author

bagder commented Mar 18, 2023

The string "0", like this:

https://github.com/curl/curl/blob/a51f90ec0f74176776f5d14b99689f9241660eaa/lib/asyn-ares.c#L784

I modified the code to instead use the string "80" as a work-around, and then it succeeds (with both glibc and c-ares).

@bradh352
Copy link
Member

Interesting use case. Typically if you don't care about the service port in a dns lookup, you'll just pass NULL to that field. But if other implementations support this, we definitely can too, its a trivial change.

bch pushed a commit to bch/curl that referenced this issue Jul 19, 2023
It turns out c-ares returns an error when asked to resolve a host name with
ares_getaddrinfo using port number 0.

Reported as a c-ares bug here: c-ares/c-ares#517

The work-around is to simply use port 80 instead, as the number typically does
not make a difference and a non-zero number works for c-ares.

Fixes curl#10759
Reported-by: Matt Jolly
Closes curl#10789
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

No branches or pull requests

2 participants