From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, famz@redhat.com, kraxel@redhat.com,
peterx@redhat.com
Subject: [Qemu-devel] [PATCH v2 1/2] usb: fix unbound stack usage for usb_mtp_add_str
Date: Thu, 10 Mar 2016 10:35:24 +0800 [thread overview]
Message-ID: <1457577325-21606-2-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1457577325-21606-1-git-send-email-peterx@redhat.com>
Use heap instead of stack.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
hw/usb/dev-mtp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 7391783..62fb7cd 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -718,7 +718,7 @@ static void usb_mtp_add_wstr(MTPData *data, const wchar_t *str)
static void usb_mtp_add_str(MTPData *data, const char *str)
{
uint32_t len = strlen(str)+1;
- wchar_t wstr[len];
+ wchar_t *wstr = g_new(wchar_t, len);
size_t ret;
ret = mbstowcs(wstr, str, len);
@@ -727,6 +727,8 @@ static void usb_mtp_add_str(MTPData *data, const char *str)
} else {
usb_mtp_add_wstr(data, wstr);
}
+
+ g_free(wstr);
}
static void usb_mtp_add_time(MTPData *data, time_t time)
--
2.4.3
next prev parent reply other threads:[~2016-03-10 2:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-10 2:35 [Qemu-devel] [PATCH v2 0/2] usb: trivial fixes Peter Xu
2016-03-10 2:35 ` Peter Xu [this message]
2016-03-18 12:55 ` [Qemu-devel] [PATCH v2 1/2] usb: fix unbound stack usage for usb_mtp_add_str Gerd Hoffmann
2016-03-10 2:35 ` [Qemu-devel] [PATCH v2 2/2] usb: trivial cleanup " Peter Xu
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=1457577325-21606-2-git-send-email-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=famz@redhat.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--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).