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:
parent
182b391e79
commit
e3d60bc7c6
@ -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)
|
static void usb_mtp_add_str(MTPData *data, const char *str)
|
||||||
{
|
{
|
||||||
uint32_t len = strlen(str)+1;
|
uint32_t len = strlen(str)+1;
|
||||||
wchar_t wstr[len];
|
wchar_t *wstr = g_new(wchar_t, len);
|
||||||
size_t ret;
|
size_t ret;
|
||||||
|
|
||||||
ret = mbstowcs(wstr, str, len);
|
ret = mbstowcs(wstr, str, len);
|
||||||
@ -727,6 +727,8 @@ static void usb_mtp_add_str(MTPData *data, const char *str)
|
|||||||
} else {
|
} else {
|
||||||
usb_mtp_add_wstr(data, wstr);
|
usb_mtp_add_wstr(data, wstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(wstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usb_mtp_add_time(MTPData *data, time_t time)
|
static void usb_mtp_add_time(MTPData *data, time_t time)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user