⬢ DragonFlyBSD Kernel Audit
DF-5711 / fix.diff
← back to finding ↓ download raw
--- a/sys/net/netmap/netmap_vale.c
+++ b/sys/net/netmap/netmap_vale.c
@@ -350,6 +350,9 @@
 	if (i == NM_BRIDGES && b) { /* name not found, can create entry */
 		/* initialize the bridge */
 		strncpy(b->bdg_basename, name, namelen);
+		/* namelen may == IFNAMSIZ: force NUL termination (strncpy
+		   does not provide one when the source has no NUL in range) */
+		b->bdg_basename[IFNAMSIZ - 1] = '\0';
 		ND("create new bridge %s with ports %d", b->bdg_basename,
 			b->bdg_active_ports);
 		b->bdg_namelen = namelen;