Revision: 18355
http://sourceforge.net/p/edk2/code/18355
Author: hwu1225
Date: 2015-08-28 07:41:38 +0000 (Fri, 28 Aug 2015)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Feng Tian <[email protected]>
Modified Paths:
--------------
trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
Modified: trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
===================================================================
--- trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
2015-08-28 07:41:08 UTC (rev 18354)
+++ trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
2015-08-28 07:41:38 UTC (rev 18355)
@@ -2827,7 +2827,8 @@
)
{
CHAR16 *SSIdStr;
- CHAR8 *AsciiStr;
+ CHAR8 AsciiStr[33];
+ UINTN DataLen;
WIFI_DEVICE_PATH *WiFiDp;
SSIdStr = GetNextParamStr (&TextDeviceNode);
@@ -2837,9 +2838,17 @@
(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;
}
Modified: trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
===================================================================
--- trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
2015-08-28 07:41:08 UTC (rev 18354)
+++ trunk/edk2/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
2015-08-28 07:41:38 UTC (rev 18355)
@@ -1616,9 +1616,14 @@
)
{
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);
}
/**
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits