UINTN Size1;\r
UINTN Size2;\r
CHAR16 *Str;\r
+ CHAR16 *TmpStr;\r
CHAR16 *Ptr;\r
CHAR16 *LastSlash;\r
\r
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
// 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
Ptr++;\r
}\r
\r
+ FreePool (TmpStr);\r
+ \r
return Str;\r
}\r
\r