⬢ DragonFlyBSD Kernel Audit
DF-5344 / fix.diff
← back to finding ↓ download raw
--- a/sys/platform/pc64/x86_64/identcpu.c
+++ b/sys/platform/pc64/x86_64/identcpu.c
@@ -122,6 +122,13 @@
 			memcpy(brand, regs, sizeof(regs));
 			brand += sizeof(regs);
 		}
+		/*
+		 * The CPUID brand string is hypervisor/firmware controlled
+		 * and may fill all 48 bytes without a terminating NUL.
+		 * Force termination so the loops/strcpy below cannot walk
+		 * past cpu_brand[].
+		 */
+		cpu_brand[NELEM(cpu_brand) - 1] = '\0';
 	}
 
 	switch (cpu_vendor_id) {