From patchwork Mon Jul 23 20:16:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948036 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dij2mt0l"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDRt52yfz9ryn for ; Tue, 24 Jul 2018 07:01:14 +1000 (AEST) Received: from localhost ([::1]:36592 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhx9-0003xq-9U for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:01:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJb-0002oB-CR for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJZ-0004cj-Vf for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:18 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:38987) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJZ-0004br-Fs; Mon, 23 Jul 2018 16:20:17 -0400 Received: by mail-oi0-x242.google.com with SMTP id d189-v6so3481800oib.6; Mon, 23 Jul 2018 13:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ULEYDd03Iqz//9xbBei+cgWESGqVvyhuWWzmfuiHCVU=; b=dij2mt0lfJsXeZm6c7aUcTHNjYJNFcZjcgCln+hlXkDJcNenggb6HVJSdoO03eoD/e GbJ6+YtDQkrD0tuz2VnFT9zSp8Nc685hkLIGevIzeW7eH2sQ3S9Wsp4ShXrzbHKSHQJr OIcWM2sVjEcJilPoJeYmRIsBE/GtrQA3hSXRU+V3yFWm2QeVc6y1aAlYe8S317hQXhxv bShADbrlJuNP5ShYB/TFFeukiPyUrN45dY3lVjcw2HLG4DQJ9dBCIUYK0nDJ7ipFqWyt CAVTbtjwHjmOExSvsqMvNE4nwFb20SDEVc/Qt7KZOkex8ks8lQ9uzhZ5D8lo8m9ymAMM QOog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ULEYDd03Iqz//9xbBei+cgWESGqVvyhuWWzmfuiHCVU=; b=LUA8UnL93HA9eJCMh6LjmOtOOfxSAtmnFf32e5Gd9tAzy1sN4za4cy4VlcWsFfLiKr A+Gty6neCKLv99KYk4Hht2GuuZUkH9idkpS4NIbC/hyHej4fqJQ3cqik43TwuXghi8RJ PFQjW5eS7KCamsZ53CmeNE/8eLTJ2kslm5A8IIWFYX7g6Ytos/ReSl2nB4Z5XrZ5Gxnv vxk3jPlm8g60iHecfEiJjdzbq2n/dGrnVIuRlFWJHXWcwCHQlnYbl0t/u+1tEt4+uMS3 anrXiCzwBJXYWmXmnC4dbtA0vGalxBtpFCyRbZEb/6fFgowQXc/jm/nAOCVX8Go0lc1p Bpnw== X-Gm-Message-State: AOUpUlFyiouQPUAYWylYpavXoBOPuXWCI/dRNtZ1J1nBPya9yuUu/xaN +1lnQto7PH/wfPITPMUckao4OjHe6ok= X-Google-Smtp-Source: AAOMgpfHZPBTDCqtQJffJ17MnanMlwUX0P1wWEsa2zUuJzzdHfGkdkV3Wgq50w0ZkxHlFhA2sFrzvg== X-Received: by 2002:aca:4cd2:: with SMTP id z201-v6mr314896oia.318.1532377216265; Mon, 23 Jul 2018 13:20:16 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id 10-v6sm6887109oip.29.2018.07.23.13.20.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:15 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:59 -0500 Message-Id: <20180723201748.25573-51-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 50/99] usb: correctly handle Zero Length Packets 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: Gerd Hoffmann , qemu-stable@nongnu.org, =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé 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é Message-id: 20180604151421.23385-2-f4bug@amsat.org Signed-off-by: Gerd Hoffmann (cherry picked from commit bf78fb1c1b61a819a47f7a1dbecf9934b9f32a0d) Signed-off-by: Michael Roth --- 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 {