From: jouyouyun Date: Wed, 5 Nov 2025 10:03:34 +0000 (+0800) Subject: nss-resolve: fix the ip addr family validity check method X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fea7f5d68b5a6272ce8989e872a57b42121b5205;p=thirdparty%2Fsystemd.git nss-resolve: fix the ip addr family validity check method `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. --- diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c index 4edd6b5fda8..48606d75c78 100644 --- a/src/nss-resolve/nss-resolve.c +++ b/src/nss-resolve/nss-resolve.c @@ -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)) {