Overhaul handling of SRV DNS responses #81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@nils-ohlmeier, please don't merge this immediately... I am just opening this PR to allow for code review.
The new DNS test suite does (indirectly) use c-ares, but does not issue any DNS requests, except for
localhost
... the only function from c-ares which is used isares_expand_name
, which just operates on a buffer in memory and does not touch the network or have any other side effects. This does mean, however, that the tests can only run on a host which has c-ares installed. Probably I should add a check incheck_dns.c
to see if c-ares is installed.I tried running the unit tests under Valgrind and it didn't detect any memory leaks, use of uninitialized memory, buffer overruns, etc.
When I am working on the PHP interpreter, I build it with ubsan enabled, and it has helped me to catch bugs. I notice that you are using
-Wall -fstack-protector
for building the tests, which is good, but I would also love to add ubsan. (-fsanitize=undefined -fno-sanitize-recover
)The behavior of CNAME is changed a bit here. In the previous code, if
ca_tmpname
matched the name in a CNAME record,ca_tmpname
would be replaced by the value of the CNAME record... but even if it didn't match, the value of the CNAME record would still replaceca_tmpname
, and if the value of the CNAME record was an IPv4 address, it would immediately be returned as the IP address to use.Now, CNAMEs only have an effect if their name matches the value of a SRV record.
Do you think it is possible that a DNS server might first return a CNAME record and then follow it with the matching SRV record? If so, I need to modify my code to account for that possibility. Right now, it needs to see the SRV record before the CNAME, or else the CNAME will not have any effect.