summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/UefiDevicePathLib
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2015-08-28 07:41:38 +0000
committerhwu1225 <hwu1225@Edk2>2015-08-28 07:41:38 +0000
commit0cd35d739ea8c0096af0db7d920010593db5779f (patch)
tree20c4ae48f8492a2a3f7842d1808792bb4426e5c6 /MdePkg/Library/UefiDevicePathLib
parenta5cb7c824e11942a1add7a0d5fdb9a8ab0ed287d (diff)
downloadedk2-0cd35d739ea8c0096af0db7d920010593db5779f.tar.gz
edk2-0cd35d739ea8c0096af0db7d920010593db5779f.tar.bz2
edk2-0cd35d739ea8c0096af0db7d920010593db5779f.zip
MdePkg UefiDevicePathLib: Fix possible memory read/write cross boundary
The SSID field of a Wi-Fi device path node may not contain a NULL termination. Additonal handle is added to make sure no cross-boundary memory read/write will occur. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18355 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/UefiDevicePathLib')
-rw-r--r--MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c15
-rw-r--r--MdePkg/Library/UefiDevicePathLib/DevicePathToText.c7
2 files changed, 18 insertions, 4 deletions
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index 9c5436d337..6a9b389ca5 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -2827,7 +2827,8 @@ DevPathFromTextWiFi (
)
{
CHAR16 *SSIdStr;
- CHAR8 *AsciiStr;
+ CHAR8 AsciiStr[33];
+ UINTN DataLen;
WIFI_DEVICE_PATH *WiFiDp;
SSIdStr = GetNextParamStr (&TextDeviceNode);
@@ -2837,8 +2838,16 @@ DevPathFromTextWiFi (
(UINT16) sizeof (WIFI_DEVICE_PATH)
);
- AsciiStr = (CHAR8 *) WiFiDp->SSId;
- StrToAscii (SSIdStr, &AsciiStr);
+ if (NULL != SSIdStr) {
+ DataLen = StrLen (SSIdStr);
+ if (StrLen (SSIdStr) > 32) {
+ SSIdStr[32] = L'\0';
+ DataLen = 32;
+ }
+
+ UnicodeStrToAsciiStr (SSIdStr, AsciiStr);
+ CopyMem (WiFiDp->SSId, AsciiStr, DataLen);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;
}
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index 0774fd8c17..363830bd32 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -1616,9 +1616,14 @@ DevPathToTextWiFi (
)
{
WIFI_DEVICE_PATH *WiFi;
+ UINT8 SSId[33];
WiFi = DevPath;
- UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", WiFi->SSId);
+
+ SSId[32] = '\0';
+ CopyMem (SSId, WiFi->SSId, 32);
+
+ UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", SSId);
}
/**