]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigFileExplorer.c
SecurityPkg: Add FileExplorerLib.inf to the dsc file
[mirror_edk2.git] / SecurityPkg / VariableAuthenticated / SecureBootConfigDxe / SecureBootConfigFileExplorer.c
index b731865ed774058945756582b86f856708d4e791..e1fd78db4eeba714451fde7412ea953761049ad5 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Internal file explorer functions for SecureBoot configuration module.\r
 \r
-Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<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
@@ -139,6 +139,7 @@ AppendFileName (
 {\r
   UINTN   Size1;\r
   UINTN   Size2;\r
+  UINTN   BufferSize;\r
   CHAR16  *Str;\r
   CHAR16  *TmpStr;\r
   CHAR16  *Ptr;\r
@@ -146,18 +147,20 @@ AppendFileName (
 \r
   Size1 = StrSize (Str1);\r
   Size2 = StrSize (Str2);\r
-  Str   = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));\r
+  BufferSize = Size1 + Size2 + sizeof (CHAR16);\r
+  Str   = AllocateZeroPool (BufferSize);\r
   ASSERT (Str != NULL);\r
 \r
-  TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));\r
+  TmpStr = AllocateZeroPool (BufferSize);\r
   ASSERT (TmpStr != NULL);\r
 \r
-  StrCat (Str, Str1);\r
+  StrCatS (Str, BufferSize / sizeof (CHAR16), Str1);\r
+\r
   if (!((*Str == '\\') && (*(Str + 1) == 0))) {\r
-    StrCat (Str, L"\\");\r
+    StrCatS (Str, BufferSize / sizeof (CHAR16), L"\\");\r
   }\r
 \r
-  StrCat (Str, Str2);\r
+  StrCatS (Str, BufferSize / sizeof (CHAR16), Str2);\r
 \r
   Ptr       = Str;\r
   LastSlash = Str;\r
@@ -170,11 +173,11 @@ AppendFileName (
       //\r
 \r
       //\r
-      // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings\r
+      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings\r
       // that overlap.\r
       //\r
-      StrCpy (TmpStr, Ptr + 3);\r
-      StrCpy (LastSlash, TmpStr);\r
+      StrCpyS (TmpStr, BufferSize / sizeof (CHAR16), Ptr + 3);\r
+      StrCpyS (LastSlash, BufferSize / sizeof (CHAR16), TmpStr);\r
       Ptr = LastSlash;\r
     } else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {\r
       //\r
@@ -182,11 +185,11 @@ AppendFileName (
       //\r
 \r
       //\r
-      // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings\r
+      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings\r
       // that overlap.\r
       //\r
-      StrCpy (TmpStr, Ptr + 2);\r
-      StrCpy (Ptr, TmpStr);\r
+      StrCpyS (TmpStr, BufferSize / sizeof (CHAR16), Ptr + 2);\r
+      StrCpyS (Ptr, BufferSize / sizeof (CHAR16), TmpStr);\r
       Ptr = LastSlash;\r
     } else if (*Ptr == '\\') {\r
       LastSlash = Ptr;\r
@@ -652,7 +655,6 @@ FindFileSystem (
 {\r
   UINTN                     NoBlkIoHandles;\r
   UINTN                     NoSimpleFsHandles;\r
-  UINTN                     NoLoadFileHandles;\r
   EFI_HANDLE                *BlkIoHandle;\r
   EFI_HANDLE                *SimpleFsHandle;\r
   UINT16                    *VolumeLabel;\r
@@ -669,7 +671,6 @@ FindFileSystem (
 \r
 \r
   NoSimpleFsHandles = 0;\r
-  NoLoadFileHandles = 0;\r
   OptionNumber      = 0;\r
   InitializeListHead (&FsOptionMenu.Head);\r
 \r