⬢ DragonFlyBSD Kernel Audit
DF-4876 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/disk/nata/atapi-fd.c	2026-09-24 17:15:01.460690390 +0000
+++ b/sys/dev/disk/nata/atapi-fd.c	2026-09-24 17:15:40.656180775 +0000
@@ -356,6 +356,17 @@
     int timeout = 20;
     int error, count;
 
+    /*
+     * The ATAPI device controls how many bytes it actually transfers;
+     * a short (but successful) READ_CAPACITY / MODE_SENSE response
+     * leaves the tail of these stack structs uninitialized, and the
+     * values below are then used as driver geometry.  Zero them first.
+     * (DF-4876)
+     */
+    bzero(&capacity, sizeof(capacity));
+    bzero(&capacity_big, sizeof(capacity_big));
+    bzero(&capabilities, sizeof(capabilities));
+
     fdp->mediasize = 0;
 
     /* wait for device to get ready */