yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
Blob Blame History Raw
From 744a9df71d68005c83f01ddde142f1b08c8fc69c Mon Sep 17 00:00:00 2001
From: Michael S. Tsirkin <mst@redhat.com>
Date: Wed, 14 May 2014 08:35:57 +0200
Subject: [PATCH 18/31] usb: sanity check setup_index+setup_len in post_load

RH-Author: Michael S. Tsirkin <mst@redhat.com>
Message-id: <1400056525-6869-1-git-send-email-mst@redhat.com>
Patchwork-id: 58864
O-Subject: [PATCH qemu-kvm RHEL7.1 1/2] usb: sanity check setup_index+setup_len in post_load
Bugzilla: 1095747
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>

From: Gerd Hoffmann <kraxel@redhat.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit c60174e847082ab9f70720f86509a3353f816fad)

Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7452039
Tested: lightly on developer's box
Bugzilla: 1095743
---
 hw/usb/bus.c | 4 ++++
 1 file changed, 4 insertions(+)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 hw/usb/bus.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index fe6bd13..e0c3a77 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -49,6 +49,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;
 }
 
-- 
1.7.1