From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 28 Aug 2013 15:09:30 +0000 (+0200)
Subject: usb: sanity check setup_index+setup_len in post_load
X-Git-Tag: v1.7.0-rc0~128^2~3
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c60174e847082ab9f70720f86509a3353f816fad;p=users%2Fdwmw2%2Fqemu.git

usb: sanity check setup_index+setup_len in post_load

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 82ca6a13e8..72d5b92225 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -47,6 +47,10 @@ static int usb_device_post_load(void *opaque, int version_id)
     } else {
         dev->attached = 1;
     }
+    if (dev->setup_index >= sizeof(dev->data_buf) ||
+        dev->setup_len >= sizeof(dev->data_buf)) {
+        return -EINVAL;
+    }
     return 0;
 }