From 4d2b5066317d3e16dc8041a3e62d3bfe1c90bb02 Mon Sep 17 00:00:00 2001 From: Ruiyu Ni Date: Thu, 2 Aug 2018 15:48:52 +0800 Subject: SourceLevelDebugPkg/Usb3: Make sure data from HW can fit in buffer Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Hao A Wu Reviewed-by: Hao Wu Reviewed-by: Star Zeng --- .../DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Transfer.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'SourceLevelDebugPkg') 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; -- cgit v1.2.3