]> 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)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 6 Nov 2025 23:38:13 +0000 (23:38 +0000)
`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.

(cherry picked from commit fea7f5d68b5a6272ce8989e872a57b42121b5205)

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)) {