From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 1/3] usb: correctly handle Zero Length Packets
Date: Mon, 4 Jun 2018 12:14:19 -0300 [thread overview]
Message-ID: <20180604151421.23385-2-f4bug@amsat.org> (raw)
In-Reply-To: <20180604151421.23385-1-f4bug@amsat.org>
USB Specification Revision 2.0, §5.5.3:
The Data stage of a control transfer from an endpoint to the host is complete when the endpoint does one of the following:
• Has transferred exactly the amount of data specified during the Setup stage
• Transfers a packet with a payload size less than wMaxPacketSize or transfers a zero-length packet"
hw/usb/redirect.c:802:9: warning: Declared variable-length array (VLA) has zero size
uint8_t buf[size];
^~~~~~~~~~~ ~~~~
Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/usb/redirect.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 65a9196c1a..58e8f7f5bd 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -795,7 +795,7 @@ static void usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p,
usbredirparser_peer_has_cap(dev->parser,
usb_redir_cap_32bits_bulk_length));
- if (ep & USB_DIR_IN) {
+ if (ep & USB_DIR_IN || size == 0) {
usbredirparser_send_bulk_packet(dev->parser, p->id,
&bulk_packet, NULL, 0);
} else {
--
2.17.1
next prev parent reply other threads:[~2018-06-04 15:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-04 15:14 [Qemu-devel] [PATCH v2 0/3] usb: fix bugs reported by Clang Static Analyzer Philippe Mathieu-Daudé
2018-06-04 15:14 ` Philippe Mathieu-Daudé [this message]
2018-06-04 15:14 ` [Qemu-devel] [PATCH v2 2/3] usb/dev-mtp: Fix use of uninitialized values Philippe Mathieu-Daudé
2018-06-04 15:14 ` [Qemu-devel] [PATCH v2 3/3] " Philippe Mathieu-Daudé
2018-06-05 9:21 ` Gerd Hoffmann
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=20180604151421.23385-2-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=kraxel@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).