]> git.proxmox.com Git - mirror_qemu.git/commitdiff
usb-redir: fix stack overflow in usbredir_log_data
authorGerd Hoffmann <kraxel@redhat.com>
Tue, 9 May 2017 11:01:28 +0000 (13:01 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 31 Aug 2017 16:51:16 +0000 (11:51 -0500)
Don't reinvent a broken wheel, just use the hexdump function we have.

Impact: low, broken code doesn't run unless you have debug logging
enabled.

Reported-by: 李强 <liqiang6-s@360.cn>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20170509110128.27261-1-kraxel@redhat.com
(cherry picked from commit bd4a683505b27adc1ac809f71e918e58573d851d)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/usb/redirect.c

index 0efe62f725336c7cabf2ae1fd482f64de002f59f..eb70dc721846f0f2158279c8f7e44b22fa22efec 100644 (file)
@@ -229,21 +229,10 @@ static void usbredir_log(void *priv, int level, const char *msg)
 static void usbredir_log_data(USBRedirDevice *dev, const char *desc,
     const uint8_t *data, int len)
 {
-    int i, j, n;
-
     if (dev->debug < usbredirparser_debug_data) {
         return;
     }
-
-    for (i = 0; i < len; i += j) {
-        char buf[128];
-
-        n = sprintf(buf, "%s", desc);
-        for (j = 0; j < 8 && i + j < len; j++) {
-            n += sprintf(buf + n, " %02X", data[i + j]);
-        }
-        error_report("%s", buf);
-    }
+    qemu_hexdump((char *)data, stderr, desc, len);
 }
 
 /*