From 6a180670f8146c3f7397b29c553780fa0085b0c2 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Wed, 23 Apr 2025 16:40:57 -0300 Subject: [PATCH] nss: Fix UB on test-netdb The gethostname is defined as not accepting NULL arguments, so use a minimal size for initial call. --- nss/test-netdb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nss/test-netdb.c b/nss/test-netdb.c index 3911c3c42a..b7125cfed1 100644 --- a/nss/test-netdb.c +++ b/nss/test-netdb.c @@ -178,6 +178,9 @@ test_hosts (void) hptr1 = gethostbyname2 ("localhost", AF_INET); output_hostent ("gethostbyname2 (\"localhost\", AF_INET)", hptr1); + name = xmalloc (2); + namelen += 2; + while (gethostname (name, namelen) < 0 && errno == ENAMETOOLONG) { namelen += 2; /* tiny increments to test a lot */ -- 2.47.2