[Git][slirp/libslirp][master] apple: Fix getting IPv4 DNS server address when IPv4 and IPv4 are interleaved

Samuel Thibault (@sthibaul) gitlab at gitlab.freedesktop.org
Wed Mar 26 07:45:58 UTC 2025



Samuel Thibault pushed to branch master at slirp / libslirp


Commits:
73590414 by Samuel Thibault at 2025-03-26T08:45:44+01:00
apple: Fix getting IPv4 DNS server address when IPv4 and IPv4 are interleaved

When getting an IPv4 DNS server address, if libresolv returns

IPv4
IPv6
IPv4
IPv6

(or just IPv4 and IPv6)

we would still have found == 1 on the second iteration and thus take the
IPv6 even if it's not the proper af. We can as well just completely ignore
the non-matching af entries.

Fixes #85

- - - - -


1 changed file:

- src/slirp.c


Changes:

=====================================
src/slirp.c
=====================================
@@ -289,9 +289,12 @@ static int get_dns_addr_libresolv(int af, void *pdns_addr, void *cached_addr,
     found = 0;
     DEBUG_MISC("IP address of your DNS(s):");
     for (int i = 0; i < count; i++) {
-        if (af == servers[i].sin.sin_family) {
-            found++;
+        if (af != servers[i].sin.sin_family) {
+            continue;
         }
+
+        found++;
+
         if (af == AF_INET) {
             addr = &servers[i].sin.sin_addr;
         } else { // af == AF_INET6



View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/commit/735904142f95d0500c0eae6bf763e4ad24b6b9fd

-- 
View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/commit/735904142f95d0500c0eae6bf763e4ad24b6b9fd
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/slirp/attachments/20250326/aef6b344/attachment.htm>


More information about the Slirp mailing list