]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiDpLib/DpUtilities.c
ShellPkg UefiDpLib: Use correct string length for the input UnicodeBuffer
[mirror_edk2.git] / ShellPkg / Library / UefiDpLib / DpUtilities.c
index ef204ffef156eb2ac0abe437a950459ebe95e3e9..e9d8fb3adf31e363ffb67a2bdfcb202e9b7a2a16 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   Utility functions used by the Dp application.\r
 \r
-  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.\r
+  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -131,7 +132,7 @@ IsPhase(
   \r
 **/\r
 VOID\r
-GetShortPdbFileName (\r
+DpGetShortPdbFileName (\r
   IN  CHAR8     *PdbFileName,\r
   OUT CHAR16    *UnicodeBuffer\r
   )\r
@@ -141,10 +142,10 @@ GetShortPdbFileName (
   UINTN StartIndex;\r
   UINTN EndIndex;\r
 \r
-  ZeroMem (UnicodeBuffer, DXE_PERFORMANCE_STRING_LENGTH * sizeof (CHAR16));\r
+  ZeroMem (UnicodeBuffer, (DP_GAUGE_STRING_LENGTH + 1) * sizeof (CHAR16));\r
 \r
   if (PdbFileName == NULL) {\r
-    StrnCpy (UnicodeBuffer, L" ", 1);\r
+    StrnCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ", 1);\r
   } else {\r
     StartIndex = 0;\r
     for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)\r
@@ -163,8 +164,8 @@ GetShortPdbFileName (
     for (IndexA = StartIndex; IndexA < EndIndex; IndexA++) {\r
       UnicodeBuffer[IndexU] = (CHAR16) PdbFileName[IndexA];\r
       IndexU++;\r
-      if (IndexU >= DXE_PERFORMANCE_STRING_LENGTH) {\r
-        UnicodeBuffer[DXE_PERFORMANCE_STRING_LENGTH] = 0;\r
+      if (IndexU >= DP_GAUGE_STRING_LENGTH) {\r
+        UnicodeBuffer[DP_GAUGE_STRING_LENGTH] = 0;\r
         break;\r
       }\r
     }\r
@@ -188,7 +189,7 @@ GetShortPdbFileName (
 \r
 **/\r
 VOID\r
-GetNameFromHandle (\r
+DpGetNameFromHandle (\r
   IN EFI_HANDLE   Handle\r
   )\r
 {\r
@@ -236,7 +237,7 @@ GetNameFromHandle (
     PdbFileName = PeCoffLoaderGetPdbPointer (Image->ImageBase);\r
 \r
     if (PdbFileName != NULL) {\r
-      GetShortPdbFileName (PdbFileName, mGaugeString);\r
+      DpGetShortPdbFileName (PdbFileName, mGaugeString);\r
       return;\r
     }\r
   }\r
@@ -261,7 +262,7 @@ GetNameFromHandle (
                                );\r
     if (!EFI_ERROR (Status)) {\r
       SHELL_FREE_NON_NULL (PlatformLanguage);\r
-      StrnCpy (mGaugeString, StringPtr, DP_GAUGE_STRING_LENGTH);\r
+      StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);\r
       mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
       return;\r
     }\r
@@ -305,7 +306,7 @@ GetNameFromHandle (
         //\r
         // Method 3. Get the name string from FFS UI section\r
         //\r
-        StrnCpy (mGaugeString, NameString, DP_GAUGE_STRING_LENGTH);\r
+        StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString, DP_GAUGE_STRING_LENGTH);\r
         mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
         FreePool (NameString);\r
       } else {\r
@@ -321,7 +322,7 @@ GetNameFromHandle (
       //\r
       NameString = ConvertDevicePathToText (LoadedImageDevicePath, TRUE, FALSE);\r
       if (NameString != NULL) {\r
-        StrnCpy (mGaugeString, NameString, DP_GAUGE_STRING_LENGTH);\r
+        StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString, DP_GAUGE_STRING_LENGTH);\r
         mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
         FreePool (NameString);\r
         return;\r
@@ -334,7 +335,7 @@ GetNameFromHandle (
   //\r
   StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_ERROR_NAME), NULL);\r
   ASSERT (StringPtr != NULL);\r
-  StrnCpy (mGaugeString, StringPtr, DP_GAUGE_STRING_LENGTH);\r
+  StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);\r
   FreePool (StringPtr);\r
 }\r
 \r