]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/DxeCorePerformanceLib: Switch to UnicodeStrnToAsciiStrS
authorJeff Brasen <jbrasen@nvidia.com>
Mon, 22 Jun 2020 18:20:16 +0000 (02:20 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 21 Jul 2020 14:47:24 +0000 (14:47 +0000)
UnicodeStrToAsciiStrS requires that the source string is shorter than
the destination buffer and will ASSERT if this is not true. Switch to
UnicodeStrnToAsciiStrS as there are cases where the source string is
longer than the buffer allocated for the device path.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c

index f500e20b320bc7fbc0606586a71c204d992bc185..d378c59dd9648e4af439f82a569b330ad450681d 100644 (file)
@@ -837,7 +837,7 @@ GetDeviceInfoFromHandleAndUpdateLength (
       ControllerNameStringSize = FPDT_MAX_PERF_RECORD_SIZE - (*Length) - 1;\r
     }\r
 \r
-    UnicodeStrToAsciiStrS(StringPtr, ComponentNameString, ControllerNameStringSize);\r
+    UnicodeStrnToAsciiStrS(StringPtr, ControllerNameStringSize - 1, ComponentNameString, ControllerNameStringSize, &ControllerNameStringSize);\r
 \r
     //\r
     // Add a space in the end of the ControllerName\r
@@ -879,7 +879,7 @@ GetDeviceInfoFromHandleAndUpdateLength (
         AsciiStringPtr = ComponentNameString;\r
       }\r
 \r
-      UnicodeStrToAsciiStrS(StringPtr, AsciiStringPtr, DevicePathStringSize);\r
+      UnicodeStrnToAsciiStrS(StringPtr, DevicePathStringSize - 1, AsciiStringPtr, DevicePathStringSize, &DevicePathStringSize);\r
       *Length += (UINT8)DevicePathStringSize;\r
       return EFI_SUCCESS;\r
     }\r