]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 23 Jul 2008 12:45:44 +0000 (12:45 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 23 Jul 2008 12:45:44 +0000 (12:45 +0000)
that overlap.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5559 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c

index 903ecfcdd322f947e79399cf0c10422618fa335e..020d63a8c615a5e9791c5514f615c2a78f99ff68 100644 (file)
@@ -1080,6 +1080,7 @@ BOpt_AppendFileName (
   UINTN   Size1;\r
   UINTN   Size2;\r
   CHAR16  *Str;\r
+  CHAR16  *TmpStr;\r
   CHAR16  *Ptr;\r
   CHAR16  *LastSlash;\r
 \r
@@ -1088,6 +1089,9 @@ BOpt_AppendFileName (
   Str   = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));\r
   ASSERT (Str != NULL);\r
 \r
+  TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16)); \r
+  ASSERT (TmpStr != NULL);\r
+\r
   StrCat (Str, Str1);\r
   if (!((*Str == '\\') && (*(Str + 1) == 0))) {\r
     StrCat (Str, L"\\");\r
@@ -1104,13 +1108,25 @@ BOpt_AppendFileName (
       // DO NOT convert the .. if it is at the end of the string. This will\r
       // break the .. behavior in changing directories.\r
       //\r
-      StrCpy (LastSlash, Ptr + 3);\r
+\r
+      //\r
+      // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings \r
+      // that overlap.\r
+      //\r
+      StrCpy (TmpStr, Ptr + 3);\r
+      StrCpy (LastSlash, TmpStr);\r
       Ptr = LastSlash;\r
     } else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {\r
       //\r
       // Convert a "\.\" to a "\"\r
       //\r
-      StrCpy (Ptr, Ptr + 2);\r
+\r
+      //\r
+      // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings \r
+      // that overlap.\r
+      //\r
+      StrCpy (TmpStr, Ptr + 2);\r
+      StrCpy (Ptr, TmpStr);\r
       Ptr = LastSlash;\r
     } else if (*Ptr == '\\') {\r
       LastSlash = Ptr;\r
@@ -1119,6 +1135,8 @@ BOpt_AppendFileName (
     Ptr++;\r
   }\r
 \r
+  FreePool (TmpStr);\r
+  \r
   return Str;\r
 }\r
 \r