|
|
9ae3a8 |
From 6116e5c19a7623b2543fbd937970da9a6e0e1ce7 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 14 Mar 2017 08:52:55 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 22/24] usb-ccid: move header size check
|
|
|
9ae3a8 |
MIME-Version: 1.0
|
|
|
9ae3a8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9ae3a8 |
Content-Transfer-Encoding: 8bit
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1489481576-26911-4-git-send-email-kraxel@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 74285
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.4 qemu-kvm PATCH 3/4] usb-ccid: move header size check
|
|
|
9ae3a8 |
Bugzilla: 1419818
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Move up header size check, so we can use header fields in sanity checks
|
|
|
9ae3a8 |
(in followup patches). Also reword the debug message.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Message-id: 1487250819-23764-3-git-send-email-kraxel@redhat.com
|
|
|
9ae3a8 |
(cherry picked from commit 7569c54642e8aa9fa03e250c7c578bd4d3747f00)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/usb/dev-smartcard-reader.c | 13 ++++++-------
|
|
|
9ae3a8 |
1 file changed, 6 insertions(+), 7 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
|
|
|
9ae3a8 |
index 672a7bf..07d15ba 100644
|
|
|
9ae3a8 |
--- a/hw/usb/dev-smartcard-reader.c
|
|
|
9ae3a8 |
+++ b/hw/usb/dev-smartcard-reader.c
|
|
|
9ae3a8 |
@@ -1001,21 +1001,20 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p)
|
|
|
9ae3a8 |
if (p->iov.size + s->bulk_out_pos > BULK_OUT_DATA_SIZE) {
|
|
|
9ae3a8 |
goto err;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- ccid_header = (CCID_Header *)s->bulk_out_data;
|
|
|
9ae3a8 |
usb_packet_copy(p, s->bulk_out_data + s->bulk_out_pos, p->iov.size);
|
|
|
9ae3a8 |
s->bulk_out_pos += p->iov.size;
|
|
|
9ae3a8 |
+ if (s->bulk_out_pos < 10) {
|
|
|
9ae3a8 |
+ DPRINTF(s, 1, "%s: header incomplete\n", __func__);
|
|
|
9ae3a8 |
+ goto err;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ ccid_header = (CCID_Header *)s->bulk_out_data;
|
|
|
9ae3a8 |
if (p->iov.size == CCID_MAX_PACKET_SIZE) {
|
|
|
9ae3a8 |
DPRINTF(s, D_VERBOSE,
|
|
|
9ae3a8 |
"usb-ccid: bulk_in: expecting more packets (%zd/%d)\n",
|
|
|
9ae3a8 |
p->iov.size, ccid_header->dwLength);
|
|
|
9ae3a8 |
return;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- if (s->bulk_out_pos < 10) {
|
|
|
9ae3a8 |
- DPRINTF(s, 1,
|
|
|
9ae3a8 |
- "%s: bad USB_TOKEN_OUT length, should be at least 10 bytes\n",
|
|
|
9ae3a8 |
- __func__);
|
|
|
9ae3a8 |
- goto err;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
DPRINTF(s, D_MORE_INFO, "%s %x %s\n", __func__,
|
|
|
9ae3a8 |
ccid_header->bMessageType,
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|