From: Adhemerval Zanella Date: Wed, 23 Apr 2025 19:40:57 +0000 (-0300) Subject: nss: Fix UB on test-netdb X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a180670f8146c3f7397b29c553780fa0085b0c2;p=thirdparty%2Fglibc.git nss: Fix UB on test-netdb The gethostname is defined as not accepting NULL arguments, so use a minimal size for initial call. --- 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 */