apple / swift-async-dns-resolver

A Swift library for asynchronous DNS requests, wrapping c-ares with Swift-friendly APIs and data structures.
Apache License 2.0
82 stars 12 forks source link

Fix bug in DNSSD IPv6 address string conversion. #14

Closed torinmr closed 6 months ago

torinmr commented 6 months ago

The old implementation converted each byte to a hexadecimal number separately, meaning that leading zeros in a byte would be dropped even in the middle of a group.

For example, the address 2620:149:110b:470e:0:0:0:e1a was incorrectly rendered as 2620:149:11b:47e:0:0:0:e1a, with zeros dropped in the 3rd and 4th octets.

I figured the most robust fix would be to use inet_ntop to format the address, which produces a correctly abbreviated address like 2620:149:110b:470e::e1a. This is the approach used in DNSResolver_c-ares.swift.

yim-lee commented 6 months ago

@swift-server-bot add to allowlist

torinmr commented 6 months ago

Hmmm, apparently ./scripts/soundness.sh exits without printing anything if you don't have swiftformat installed. I fixed the formatting issues and added a patch to soundness.sh to print an informative error message in this case, let me know if it looks good to you.

torinmr commented 6 months ago

Thanks for the review Yim! How does merging work? Looks like I don't have permission to trigger the merge myself.