DragonFlyBSD Kernel Audit
DF-1424 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/raid/iir/iir.c b/sys/dev/raid/iir/iir.c
--- a/sys/dev/raid/iir/iir.c
+++ b/sys/dev/raid/iir/iir.c
@@ -1611,19 +1611,23 @@
             if (ucmd->service == GDT_CACHESERVICE) {
                 if (ucmd->OpCode == GDT_IOCTL) {
                     cnt = ucmd->u.ioctl.param_size;
+                    if (cnt > GDT_SCRATCH_SZ)
+                        cnt = GDT_SCRATCH_SZ;
                     if (cnt != 0)
                         bcopy(gccb->gc_scratch, ucmd->data, cnt);
                 } else {
                     cnt = ucmd->u.cache.BlockCnt * GDT_SECTOR_SIZE;
+                    if (cnt > GDT_SCRATCH_SZ)
+                        cnt = GDT_SCRATCH_SZ;
                     if (cnt != 0)
                         bcopy(gccb->gc_scratch, ucmd->data, cnt);
                 }
             } else {
                 cnt = ucmd->u.raw.sdlen;
+                if (cnt > GDT_SCRATCH_SZ)
+                    cnt = GDT_SCRATCH_SZ;
                 if (cnt != 0)
                     bcopy(gccb->gc_scratch, ucmd->data, cnt);
-                if (ucmd->u.raw.sense_len != 0)
-                    bcopy(gccb->gc_scratch, ucmd->data, cnt);
             }
             gdt_free_ccb(gdt, gccb);
             if (!(gdt->sc_state & GDT_POLLING))