DragonFlyBSD Kernel Audit
DF-1824 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/raid/aac/aac_cam.c b/sys/dev/raid/aac/aac_cam.c
--- a/sys/dev/raid/aac/aac_cam.c
+++ b/sys/dev/raid/aac/aac_cam.c
@@ -440,8 +440,8 @@
 		 * Copy the CDB into the SRB.  It's only 6-16 bytes,
 		 * so a copy is not too expensive.
 		 */
-		srb->cdb_len = csio->cdb_len;
-		if (ccb->ccb_h.flags & CAM_CDB_POINTER)
+		srb->cdb_len = min(csio->cdb_len, (u_int8_t)sizeof(srb->cdb));
+		if (ccb->ccb_h.flags & CAM_CDB_POINTER)
 			bcopy(csio->cdb_io.cdb_ptr, (u_int8_t *)&srb->cdb[0],
 			    srb->cdb_len);
 		else