Reviewed-by: Liming Gao <[email protected]> > -----Original Message----- > From: Bi, Dandan > Sent: Monday, November 19, 2018 10:09 AM > To: [email protected] > Cc: Kinney, Michael D <[email protected]>; Gao, Liming > <[email protected]> > 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 <[email protected]> > Cc: Liming Gao <[email protected]> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Dandan Bi <[email protected]> > --- > 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 [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

