[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/5] usb/redir: avoid dynamic stack allocation (CVE-2021-3527)
From: |
Gerd Hoffmann |
Subject: |
[PATCH 2/5] usb/redir: avoid dynamic stack allocation (CVE-2021-3527) |
Date: |
Mon, 3 May 2021 11:14:43 +0200 |
Use autofree heap allocation instead.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/usb/redirect.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 17f06f34179a..db1a89a7cc92 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -818,7 +818,7 @@ static void usbredir_handle_bulk_data(USBRedirDevice *dev,
USBPacket *p,
usbredirparser_send_bulk_packet(dev->parser, p->id,
&bulk_packet, NULL, 0);
} else {
- uint8_t buf[size];
+ g_autofree uint8_t *buf = g_malloc(size);
usb_packet_copy(p, buf, size);
usbredir_log_data(dev, "bulk data out:", buf, size);
usbredirparser_send_bulk_packet(dev->parser, p->id,
@@ -923,7 +923,7 @@ static void
usbredir_handle_interrupt_out_data(USBRedirDevice *dev,
USBPacket *p, uint8_t ep)
{
struct usb_redir_interrupt_packet_header interrupt_packet;
- uint8_t buf[p->iov.size];
+ g_autofree uint8_t *buf = g_malloc(p->iov.size);
DPRINTF("interrupt-out ep %02X len %zd id %"PRIu64"\n", ep,
p->iov.size, p->id);
--
2.30.2
- [PATCH 0/5] usb: fix some memory allocation issues., Gerd Hoffmann, 2021/05/03
- [PATCH 3/5] usb/mtp: avoid dynamic stack allocation, Gerd Hoffmann, 2021/05/03
- [PATCH 1/5] usb/hid: avoid dynamic stack allocation, Gerd Hoffmann, 2021/05/03
- [PATCH 2/5] usb/redir: avoid dynamic stack allocation (CVE-2021-3527),
Gerd Hoffmann <=
- [PATCH 5/5] usb: limit combined packets to 1 MiB, Gerd Hoffmann, 2021/05/03
- [PATCH 4/5] usb/xhci: sanity check packet size, Gerd Hoffmann, 2021/05/03
- Re: [PATCH 0/5] usb: fix some memory allocation issues., Philippe Mathieu-Daudé, 2021/05/03