diff options
author | Peter Xu <peterx@redhat.com> | 2016-03-10 10:35:24 +0800 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2016-03-18 13:55:16 +0100 |
commit | e3d60bc7c6f26b889686ab91f7062f6a79df2494 (patch) | |
tree | b57f43562e9835b17c2197629c007a33aaf8031d /hw/usb/dev-mtp.c | |
parent | 182b391e797508deba9704cf580325e99260d8c8 (diff) |
usb: fix unbound stack usage for usb_mtp_add_str
Use heap instead of stack.
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/dev-mtp.c')
-rw-r--r-- | hw/usb/dev-mtp.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 7391783193..62fb7cd518 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) |