]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nss-resolve: fix the ip addr family validity check method
authorjouyouyun <yanbowen@uniontech.com>
Wed, 5 Nov 2025 10:03:34 +0000 (18:03 +0800)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 5 Nov 2025 22:45:40 +0000 (07:45 +0900)
`i` only counts the number of matches with the current family,
while `n_addresses` counts the number of matches with the family INET or INET6.
If the address contains both INET and INET6, `assert(i == n_addresses)` will fail.

src/nss-resolve/nss-resolve.c

index 4edd6b5fda8097759d8fae0afb6fe781d0f3a678..48606d75c78f61f7d7be53b109fbf4a2d9c7fd01 100644 (file)
@@ -418,7 +418,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
                 if (r < 0)
                         goto fail;
 
-                if (!IN_SET(q.family, AF_INET, AF_INET6))
+                if (q.family != af)
                         continue;
 
                 if (q.address_size != FAMILY_ADDRESS_SIZE(q.family)) {