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>
This commit is contained in:
Peter Xu 2016-03-10 10:35:24 +08:00 committed by Gerd Hoffmann
parent 182b391e79
commit e3d60bc7c6
1 changed files with 3 additions and 1 deletions

View File

@ -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)