⬢ DragonFlyBSD Kernel Audit
DF-2375 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/acpica/acpi_battery.c
+++ b/sys/dev/acpica/acpi_battery.c
@@ -328,9 +328,10 @@
 	    *str = '?';
     }
 
-    /* NUL-terminate the string if we reached the end. */
+    /* NUL-terminate the string if we reached the end.  Write the
+     * LAST byte, not one past the buffer (DF-2375). */
     if (i == len)
-	*str = '\0';
+	*(str - 1) = '\0';
 }
 
 /*