]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
tst-if_nameindex.c: Fix minimum buffer size
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 12 Jan 2026 20:23:33 +0000 (21:23 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 12 Jan 2026 20:24:40 +0000 (21:24 +0100)
The standard says that the buffer given to if_indextoname shall have at
least IF_NAMESIZE bytes.

inet/tst-if_nameindex.c

index c14fc64b92c5ee8e69d82c30eab720eefc406c6e..a371dc4fc17bb991973d44a01a888e1692d1bb95 100644 (file)
@@ -72,6 +72,8 @@ do_test (void)
       if (strlen (ifp->if_name) + 1 > buflen)
        buflen = strlen (ifp->if_name) + 1;
     }
+  if (buflen < IF_NAMESIZE)
+    buflen = IF_NAMESIZE;
   buffer = (char *) xmalloc (buflen);
 
   /* Check normal operation.  */