peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0101-usb-redir-fix-stack-overflow-in-usbredir_log_data.patch

335584
From: Gerd Hoffmann <kraxel@redhat.com>
335584
Date: Tue, 9 May 2017 13:01:28 +0200
335584
Subject: [PATCH] usb-redir: fix stack overflow in usbredir_log_data
335584
MIME-Version: 1.0
335584
Content-Type: text/plain; charset=UTF-8
335584
Content-Transfer-Encoding: 8bit
335584
335584
Don't reinvent a broken wheel, just use the hexdump function we have.
335584
335584
Impact: low, broken code doesn't run unless you have debug logging
335584
enabled.
335584
335584
Reported-by: 李强 <liqiang6-s@360.cn>
335584
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
335584
Message-id: 20170509110128.27261-1-kraxel@redhat.com
335584
(cherry picked from commit bd4a683505b27adc1ac809f71e918e58573d851d)
335584
---
335584
 hw/usb/redirect.c | 13 +------------
335584
 1 file changed, 1 insertion(+), 12 deletions(-)
335584
335584
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
335584
index 0efe62f725..eb70dc7218 100644
335584
--- a/hw/usb/redirect.c
335584
+++ b/hw/usb/redirect.c
335584
@@ -229,21 +229,10 @@ static void usbredir_log(void *priv, int level, const char *msg)
335584
 static void usbredir_log_data(USBRedirDevice *dev, const char *desc,
335584
     const uint8_t *data, int len)
335584
 {
335584
-    int i, j, n;
335584
-
335584
     if (dev->debug < usbredirparser_debug_data) {
335584
         return;
335584
     }
335584
-
335584
-    for (i = 0; i < len; i += j) {
335584
-        char buf[128];
335584
-
335584
-        n = sprintf(buf, "%s", desc);
335584
-        for (j = 0; j < 8 && i + j < len; j++) {
335584
-            n += sprintf(buf + n, " %02X", data[i + j]);
335584
-        }
335584
-        error_report("%s", buf);
335584
-    }
335584
+    qemu_hexdump((char *)data, stderr, desc, len);
335584
 }
335584
 
335584
 /*