From nobody Thu Nov 6 02:11:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539258267281296.8664739579101; Thu, 11 Oct 2018 04:44:27 -0700 (PDT) Received: from localhost ([::1]:33680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAZOE-0004uh-5Z for importer@patchew.org; Thu, 11 Oct 2018 07:44:26 -0400 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 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C705830832CE; Thu, 11 Oct 2018 11:26:44 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-220.phx2.redhat.com [10.3.116.220]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 838306B8E1; Thu, 11 Oct 2018 11:26:39 +0000 (UTC) From: P J P To: QEMU Developers Date: Thu, 11 Oct 2018 16:54:36 +0530 Message-Id: <20181011112436.9305-1-ppandit@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 11 Oct 2018 11:26:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] ccid-card-passthru: check buffer size parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Prasad J Pandit , Gerd Hoffmann , Arash TC Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 u= int8_t *buf, int size) PassthruState *card =3D opaque; VSCMsgHeader *hdr; =20 + assert(0 <=3D 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.", --=20 2.17.1