From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DDF0521164EFA for ; Sun, 14 Oct 2018 23:37:36 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Oct 2018 23:37:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,383,1534834800"; d="scan'208";a="78046751" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.11]) by fmsmga007.fm.intel.com with ESMTP; 14 Oct 2018 23:37:36 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Hao A Wu Date: Mon, 15 Oct 2018 14:38:28 +0800 Message-Id: <20181015063833.61304-7-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20181015063833.61304-1-ruiyu.ni@intel.com> References: <20181015063833.61304-1-ruiyu.ni@intel.com> Subject: [PATCH 06/11] SourceLevelDebugPkg/Usb3: Make sure data from HW can fit in buffer X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Oct 2018 06:37:37 -0000 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Hao A Wu --- .../DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Transfer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Transfer.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Transfer.c index fb48010a9a..fda43279a3 100644 --- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Transfer.c +++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Transfer.c @@ -556,6 +556,13 @@ XhcDataTransfer ( XhcExecTransfer (Handle, Urb, Timeout); + // + // Make sure the data received from HW can fit in the received buffer. + // + if (Urb->Completed > *DataLength) { + return EFI_DEVICE_ERROR; + } + *DataLength = Urb->Completed; Status = EFI_TIMEOUT; -- 2.16.1.windows.1