qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ccid-card-passthru: check buffer size parameter
@ 2018-10-11 11:24 P J P
  2018-10-11 11:58 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 7+ messages in thread
From: P J P @ 2018-10-11 11:24 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Gerd Hoffmann, Arash TC, Prasad J Pandit

From: Prasad J Pandit <pjp@fedoraproject.org>

While reading virtual smart card data, if buffer 'size' is negative
it would lead to memory corruption errors. Add check to avoid it.

Reported-by: Arash TC <tohidi.arash@gmail.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/usb/ccid-card-passthru.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index 0a6c657228..63ed78f4c6 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -275,6 +275,7 @@ static void ccid_card_vscard_read(void *opaque, const uint8_t *buf, int size)
     PassthruState *card = opaque;
     VSCMsgHeader *hdr;
 
+    assert(0 <= size && size < VSCARD_IN_SIZE);
     if (card->vscard_in_pos + size > VSCARD_IN_SIZE) {
         error_report("no room for data: pos %u +  size %d > %" PRId64 "."
                      " dropping connection.",
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-11 12:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-11 11:24 [Qemu-devel] [PATCH] ccid-card-passthru: check buffer size parameter P J P
2018-10-11 11:58 ` Philippe Mathieu-Daudé
2018-10-11 12:15   ` Paolo Bonzini
2018-10-11 12:29   ` P J P
2018-10-11 12:34     ` Paolo Bonzini
2018-10-11 12:38     ` Philippe Mathieu-Daudé
2018-10-11 12:50       ` P J P

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