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

Documentation says ares_options.udp_port is in network byte order #487

Closed
aaron-michaux opened this issue Oct 14, 2022 · 3 comments
Closed

Comments

@aaron-michaux
Copy link

The documentation says:

ARES_OPT_UDP_PORT unsigned short udp_port;
The port to use for queries over UDP, in network byte order. The default value is 53 (in network byte order), the standard name service port.

Yet, the code says:

  // NOTE: c-ares is assuming `options->udp_port` is in host byte order!
  if ((optmask & ARES_OPT_UDP_PORT) && channel->udp_port == -1)
    channel->udp_port = htons(options->udp_port);
@bradh352
Copy link
Member

I haven't looked into this, but did you confirm via testing the docs are wrong, or did you just happen to glance at the code?

The reason I ask is there are quite a few usages of htons and ntohs in the c-ares code involving ports, so it could be swapping twice which would mean the docs could be right.

@aaron-michaux
Copy link
Author

Hi,

I tested the code, I read the code, and I read the docs. I'm pretty sure that the docs are wrong.

bradh352 added a commit that referenced this issue Jan 18, 2023
As per #487, documentation states the port should be in network byte
order, but we can see from the test cases using MockServers on
different ports that this is not the case, it is definitely in host
byte order.

Fix By: Brad House (@bradh352)
@bradh352
Copy link
Member

fixed in a306ed4

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