You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dns: Resolver#setLocalAddress() applies the first address even when it throws #67049
How often does it reproduce? Is there a required condition?
Always. It happens whenever the second argument is rejected (two addresses of the same family,
or an invalid second address).
What is the expected behavior? Why is that the expected behavior?
A call that throws ERR_INVALID_ARG_VALUE should leave the resolver unchanged, so queries keep
going out from 127.0.0.2.
What do you see instead?
ERR_INVALID_ARG_VALUE Cannot specify two IPv4 addresses.
query from 127.0.0.3
The first address from the rejected call is already in effect.
Additional information
SetLocalAddress in src/cares_wrap.cc calls ares_set_local_ip4() / ares_set_local_ip6() for the first address before it parses and validates the second one, so every return after a rejected second argument leaves the first address applied. A possible fix is to parse and validate both arguments first (including the same-family check) and only then call ares_set_local_ip4() / ares_set_local_ip6(). I'm happy to open a PR along those lines if that approach sounds right.
This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually.
Reproduced on macOS and Linux (Node v26.11.1 and v24.22.1).
The proposed approach of validating both arguments and enforcing the same-family check before invoking ares_set_local_ip4/ares_set_local_ip6 makes complete sense. Validating upfront preserves strong exception safety so a thrown ERR_INVALID_ARG_VALUE leaves the resolver instance in its previous configuration. Looking forward to your PR!
Activity
nikolas-sapa commentedon Oct 27, 2026
Reproduced on macOS and Linux (Node v26.11.1 and v24.22.1).
The proposed approach of validating both arguments and enforcing the same-family check before invoking
ares_set_local_ip4/ares_set_local_ip6makes complete sense. Validating upfront preserves strong exception safety so a thrownERR_INVALID_ARG_VALUEleaves the resolver instance in its previous configuration. Looking forward to your PR!