summaryrefslogtreecommitdiff
path: root/MdePkg/Library
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2015-06-30 06:29:24 +0000
committerhwu1225 <hwu1225@Edk2>2015-06-30 06:29:24 +0000
commit750b4513b30066a0e42e2d3ba8e383c5709b03f0 (patch)
tree8dd02d0dc55c5e9ba8983d80a0d778ca629618e4 /MdePkg/Library
parent01a5dd0b260ee7861dcdb0ed092830441e475f88 (diff)
downloadedk2-platforms-750b4513b30066a0e42e2d3ba8e383c5709b03f0.tar.xz
MdePkg UefiDevicePathLib: Remove unsafe string functions
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17741 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library')
-rw-r--r--MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index d58f06905a..a05f42ce00 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -2596,7 +2596,16 @@ DevPathFromTextUsbWwid (
UsbWwid->VendorId = (UINT16) Strtoi (VIDStr);
UsbWwid->ProductId = (UINT16) Strtoi (PIDStr);
UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr);
- StrnCpy ((CHAR16 *) ((UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH)), SerialNumberStr, SerialNumberStrLen);
+
+ //
+ // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
+ // Therefore, the '\0' will not be copied.
+ //
+ CopyMem (
+ (UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH),
+ SerialNumberStr,
+ SerialNumberStrLen * sizeof (CHAR16)
+ );
return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid;
}
@@ -2759,8 +2768,8 @@ DevPathFromTextBluetooth (
if (TempNumBuffer == NULL) {
break;
}
- StrnCpy (TempNumBuffer, L"0x", TempBufferSize / sizeof (CHAR16));
- StrnCat (TempNumBuffer + StrLen (L"0x"), Walker, TempBufferSize / sizeof (CHAR16) - StrLen (L"0x") );
+ StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), L"0x");
+ StrCatS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), Walker);
BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi (TempNumBuffer);
FreePool (TempNumBuffer);
Index--;
@@ -2982,7 +2991,7 @@ DevPathFromTextFilePath (
(UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)
);
- StrCpy (File->PathName, TextDeviceNode);
+ StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
return (EFI_DEVICE_PATH_PROTOCOL *) File;
}