]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
MdePkg UefiDevicePathLib: Validate before touch input buffer.
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / DevicePathToText.c
index 0774fd8c17a4b24d3c3ce1d7099d2250058925c0..5922deeea840b2a75eb24565e61890e043e9a93c 100644 (file)
@@ -42,6 +42,7 @@ UefiDevicePathLibCatPrint (
 \r
   VA_START (Args, Fmt);\r
   Count = SPrintLength (Fmt, Args);\r
+  VA_END(Args);\r
 \r
   if ((Str->Count + (Count + 1)) * sizeof (CHAR16) > Str->Capacity) {\r
     Str->Capacity = (Str->Count + (Count + 1) * 2) * sizeof (CHAR16);\r
@@ -52,6 +53,7 @@ UefiDevicePathLibCatPrint (
                  );\r
     ASSERT (Str->Str != NULL);\r
   }\r
+  VA_START (Args, Fmt);\r
   UnicodeVSPrint (&Str->Str[Str->Count], Str->Capacity - Str->Count * sizeof (CHAR16), Fmt, Args);\r
   Str->Count += Count;\r
   \r
@@ -822,6 +824,37 @@ DevPathToTextSd (
     );\r
 }\r
 \r
+/**\r
+  Converts a EMMC (Embedded MMC) device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextEmmc (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  EMMC_DEVICE_PATH             *Emmc;\r
+\r
+  Emmc = DevPath;\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"Emmc(0x%x)",\r
+    Emmc->SlotNumber\r
+    );\r
+}\r
+\r
 /**\r
   Converts a 1394 device path structure to its string representative.\r
 \r
@@ -1616,9 +1649,14 @@ DevPathToTextWiFi (
   )\r
 {\r
   WIFI_DEVICE_PATH      *WiFi;\r
+  UINT8                 SSId[33];\r
 \r
   WiFi = DevPath;\r
-  UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", WiFi->SSId);\r
+\r
+  SSId[32] = '\0';\r
+  CopyMem (SSId, WiFi->SSId, 32);\r
+\r
+  UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", SSId);\r
 }\r
 \r
 /**\r
@@ -2134,6 +2172,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLib
   {MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP,            DevPathToTextNVMe           },\r
   {MESSAGING_DEVICE_PATH, MSG_UFS_DP,                       DevPathToTextUfs            },\r
   {MESSAGING_DEVICE_PATH, MSG_SD_DP,                        DevPathToTextSd             },\r
+  {MESSAGING_DEVICE_PATH, MSG_EMMC_DP,                      DevPathToTextEmmc           },\r
   {MESSAGING_DEVICE_PATH, MSG_1394_DP,                      DevPathToText1394           },\r
   {MESSAGING_DEVICE_PATH, MSG_USB_DP,                       DevPathToTextUsb            },\r
   {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP,                  DevPathToTextUsbWWID        },\r