nss: Fix UB on test-netdb

The gethostname is defined as not accepting NULL arguments, so
use a minimal size for initial call.
This commit is contained in:
Adhemerval Zanella 2025-04-23 16:40:57 -03:00
parent dc4b8962cb
commit 6a180670f8
1 changed files with 3 additions and 0 deletions

View File

@ -178,6 +178,9 @@ test_hosts (void)
hptr1 = gethostbyname2 ("localhost", AF_INET); hptr1 = gethostbyname2 ("localhost", AF_INET);
output_hostent ("gethostbyname2 (\"localhost\", AF_INET)", hptr1); output_hostent ("gethostbyname2 (\"localhost\", AF_INET)", hptr1);
name = xmalloc (2);
namelen += 2;
while (gethostname (name, namelen) < 0 && errno == ENAMETOOLONG) while (gethostname (name, namelen) < 0 && errno == ENAMETOOLONG)
{ {
namelen += 2; /* tiny increments to test a lot */ namelen += 2; /* tiny increments to test a lot */