summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/UefiDevicePathLib
diff options
context:
space:
mode:
authorDandan Bi <dandan.bi@intel.com>2018-11-19 09:33:14 +0800
committerLiming Gao <liming.gao@intel.com>2018-11-21 13:01:02 +0800
commitd8e702693a8c292220131dc4234a36e2c9fff614 (patch)
tree5fb271bc1ad1c93d641761ad0d1f49f091720880 /MdePkg/Library/UefiDevicePathLib
parent63f151aadb0a96467cd73f8c648c223f13fe37ba (diff)
downloadedk2-d8e702693a8c292220131dc4234a36e2c9fff614.tar.gz
edk2-d8e702693a8c292220131dc4234a36e2c9fff614.tar.bz2
edk2-d8e702693a8c292220131dc4234a36e2c9fff614.zip
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 <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdePkg/Library/UefiDevicePathLib')
-rw-r--r--MdePkg/Library/UefiDevicePathLib/DevicePathToText.c2
1 files changed, 1 insertions, 1 deletions
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
@@ -972,7 +972,7 @@ DevPathToTextUsbWWID (
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
//