Reviewed-by: Liming Gao
> -Original Message-
> From: Bi, Dandan
> Sent: Monday, November 19, 2018 10:09 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D ; Gao, Liming
>
> Subject: [patch] MdePkg: check Length para before use in DevPathToTextUsbWWID
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1336
>
> In function DevPathToTextUsbWWID, the Length parameter is used
> without check. This patch is to add check before using it.
>
> Cc: Michael D Kinney
> Cc: Liming Gao
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi
> ---
> MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
> b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
> index 97d279eeb2..678f3d0a92 100644
> --- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
> +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
> @@ -970,11 +970,11 @@ DevPathToTextUsbWWID (
>
>UsbWWId = DevPath;
>
>SerialNumberStr = (CHAR16 *) ((UINT8 *) UsbWWId + sizeof
> (USB_WWID_DEVICE_PATH));
>Length = (UINT16) ((DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *)
> UsbWWId) - sizeof (USB_WWID_DEVICE_PATH)) /
> sizeof (CHAR16));
> - if (SerialNumberStr [Length - 1] != 0) {
> + if (Length >= 1 && SerialNumberStr [Length - 1] != 0) {
> //
> // In case no NULL terminator in SerialNumber, create a new one with
> NULL terminator
> //
> NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16),
> SerialNumberStr);
> ASSERT (NewStr != NULL);
> --
> 2.18.0.windows.1
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel