]> Git Repo - qemu.git/commitdiff
hw/net/can: sja1000 fix buff2frame_bas and buff2frame_pel when dlc is out of std...
authorPavel Pisa <[email protected]>
Thu, 29 Jul 2021 12:33:27 +0000 (14:33 +0200)
committerJason Wang <[email protected]>
Mon, 2 Aug 2021 04:19:18 +0000 (12:19 +0800)
Problem reported by openEuler fuzz-sig group.

The buff2frame_bas function (hw\net\can\can_sja1000.c)
infoleak(qemu5.x~qemu6.x) or stack-overflow(qemu 4.x).

Reported-by: Qiang Ning <[email protected]>
Cc: [email protected]
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Pavel Pisa <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
hw/net/can/can_sja1000.c

index 42d2f99dfb1d3cd3fa26f56ccb8d94eba3814735..34eea684ced278738bdb26327100b285fa941bd0 100644 (file)
@@ -275,6 +275,10 @@ static void buff2frame_pel(const uint8_t *buff, qemu_can_frame *frame)
     }
     frame->can_dlc = buff[0] & 0x0f;
 
+    if (frame->can_dlc > 8) {
+        frame->can_dlc = 8;
+    }
+
     if (buff[0] & 0x80) { /* Extended */
         frame->can_id |= QEMU_CAN_EFF_FLAG;
         frame->can_id |= buff[1] << 21; /* ID.28~ID.21 */
@@ -311,6 +315,10 @@ static void buff2frame_bas(const uint8_t *buff, qemu_can_frame *frame)
     }
     frame->can_dlc = buff[1] & 0x0f;
 
+    if (frame->can_dlc > 8) {
+        frame->can_dlc = 8;
+    }
+
     for (i = 0; i < frame->can_dlc; i++) {
         frame->data[i] = buff[2 + i];
     }
This page took 0.02724 seconds and 4 git commands to generate.