]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: make NSS IPv4 tuple bounds explicit
authorLuca Boccassi <luca.boccassi@gmail.com>
Wed, 15 Jul 2026 11:07:20 +0000 (12:07 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 15 Jul 2026 16:51:48 +0000 (17:51 +0100)
gaih_addrtuple.addr has room for an IPv6 address, while IPv4 uses only
the first struct in_addr. Express the remaining range directly in terms
of that type so static analysis can prove the access remains within the
array.

CID#1663899

Follow-up for 2d85bba6b9ddd20b74992c740fab7f82c9c03f01

src/test/test-nss-hosts.c

index 61f9b153f8c26eae5515d6aa9da7a9f88f453526..761677430ad7fe2e4d939db0988c5bcb4742fa74 100644 (file)
@@ -74,8 +74,8 @@ static void assert_myhostname_gaih_addrtuples(const struct gaih_addrtuple *tuple
         for (const struct gaih_addrtuple *it = tuples; it; it = it->next)
                 if (it->family == AF_INET)
                         assert_se(memeqzero(
-                                        (const uint8_t*) it->addr + FAMILY_ADDRESS_SIZE(AF_INET),
-                                        sizeof(it->addr) - FAMILY_ADDRESS_SIZE(AF_INET)));
+                                        (const uint8_t*) it->addr + sizeof(struct in_addr),
+                                        sizeof(it->addr) - sizeof(struct in_addr)));
 }
 
 static void print_struct_hostent(struct hostent *host, const char *canon) {