diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-07-23 12:45:44 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-07-23 12:45:44 +0000 |
commit | 11c11e4ecf4c3bb41ede73fe88ac29dc67195aa9 (patch) | |
tree | 33c5a88ef20c872bc0097ac9d97b5bd56982d01b /MdeModulePkg | |
parent | 40f26b8f443f271f0b6d9df3c0214df4269b7485 (diff) | |
download | edk2-11c11e4ecf4c3bb41ede73fe88ac29dc67195aa9.zip edk2-11c11e4ecf4c3bb41ede73fe88ac29dc67195aa9.tar.gz edk2-11c11e4ecf4c3bb41ede73fe88ac29dc67195aa9.tar.bz2 |
Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings
that overlap.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5559 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c b/MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c index 903ecfc..020d63a 100644 --- a/MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c +++ b/MdeModulePkg/Universal/BdsDxe/BootMaint/BootOption.c @@ -1080,6 +1080,7 @@ BOpt_AppendFileName ( UINTN Size1;
UINTN Size2;
CHAR16 *Str;
+ CHAR16 *TmpStr;
CHAR16 *Ptr;
CHAR16 *LastSlash;
@@ -1088,6 +1089,9 @@ BOpt_AppendFileName ( Str = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));
ASSERT (Str != NULL);
+ TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));
+ ASSERT (TmpStr != NULL);
+
StrCat (Str, Str1);
if (!((*Str == '\\') && (*(Str + 1) == 0))) {
StrCat (Str, L"\\");
@@ -1104,13 +1108,25 @@ BOpt_AppendFileName ( // DO NOT convert the .. if it is at the end of the string. This will
// break the .. behavior in changing directories.
//
- StrCpy (LastSlash, Ptr + 3);
+
+ //
+ // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings
+ // that overlap.
+ //
+ StrCpy (TmpStr, Ptr + 3);
+ StrCpy (LastSlash, TmpStr);
Ptr = LastSlash;
} else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {
//
// Convert a "\.\" to a "\"
//
- StrCpy (Ptr, Ptr + 2);
+
+ //
+ // Use TmpStr as a backup, as StrCpy in BaseLib does not handle copy of two strings
+ // that overlap.
+ //
+ StrCpy (TmpStr, Ptr + 2);
+ StrCpy (Ptr, TmpStr);
Ptr = LastSlash;
} else if (*Ptr == '\\') {
LastSlash = Ptr;
@@ -1119,6 +1135,8 @@ BOpt_AppendFileName ( Ptr++;
}
+ FreePool (TmpStr);
+
return Str;
}
|