qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Manos Pitsidianakis <el13635@mail.ntua.gr>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] usb-redir: fix stack overflow in usbredir_log_data
Date: Tue, 9 May 2017 14:40:06 +0300	[thread overview]
Message-ID: <20170509114006.les3miuqfx4oebat@post> (raw)
In-Reply-To: <20170509110128.27261-1-kraxel@redhat.com>

Shouldn't we be checking if a monitor has been set instead of printing 
to stderr anyway?

On Tue, May 09, 2017 at 01:01:28PM +0200, Gerd Hoffmann wrote:
>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>
>---
> hw/usb/redirect.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
>diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
>index b001a27f05..ad5ef783a6 100644
>--- a/hw/usb/redirect.c
>+++ b/hw/usb/redirect.c
>@@ -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);
> }
>
> /*
>-- 
>2.9.3
>
>
>

      reply	other threads:[~2017-05-09 12:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09 11:01 [Qemu-devel] [PATCH] usb-redir: fix stack overflow in usbredir_log_data Gerd Hoffmann
2017-05-09 11:40 ` Manos Pitsidianakis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170509114006.les3miuqfx4oebat@post \
    --to=el13635@mail.ntua.gr \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).