From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAZ7O-00087r-HM for qemu-devel@nongnu.org; Thu, 11 Oct 2018 07:27:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAZ7J-0000MW-Ft for qemu-devel@nongnu.org; Thu, 11 Oct 2018 07:27:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45664) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gAZ7F-00007y-Lj for qemu-devel@nongnu.org; Thu, 11 Oct 2018 07:26:55 -0400 From: P J P Date: Thu, 11 Oct 2018 16:54:36 +0530 Message-Id: <20181011112436.9305-1-ppandit@redhat.com> Subject: [Qemu-devel] [PATCH] ccid-card-passthru: check buffer size parameter List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers Cc: Gerd Hoffmann , Arash TC , Prasad J Pandit From: Prasad J Pandit 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 Signed-off-by: Prasad J Pandit --- 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