⬢ DragonFlyBSD Kernel Audit
DF-2722 / fix.diff
← back to finding ↓ download raw
--- sys/kern/kern_slaballoc.c	2026-06-29 12:51:19.000000000 +0000
+++ /tmp/opencode/v26/fixtree/sys/kern/kern_slaballoc.c	2026-10-24 16:33:07.741716173 +0000
@@ -1321,10 +1321,10 @@
 
     if (str == NULL)
 	return(NULL);
-    zlen = strnlen(str, maxlen) + 1;
-    nstr = _kmalloc_debug(zlen, type, M_WAITOK, file, line);
+    zlen = strnlen(str, maxlen);
+    nstr = _kmalloc_debug(zlen + 1, type, M_WAITOK, file, line);
     bcopy(str, nstr, zlen);
-    nstr[zlen - 1] = '\0';
+    nstr[zlen] = '\0';
     return(nstr);
 }