X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellLib%2FUefiShellLib.c;h=66fcc9f89d33947ca60260a0eddea00df566cc11;hp=54b6a43e038053e5f72c77fafe33d9ed03398d46;hb=0158294b9b91d349d6842012cf00c9e03213c6f2;hpb=b4b9fbc40e84f066e403497d5e99ad28a56aa113 diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 54b6a43e03..66fcc9f89d 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -2005,6 +2005,7 @@ CopyReplace( IN CONST CHAR16 *FindTarget, IN CONST CHAR16 *ReplaceWith ){ + UINTN Size; if ( (SourceString == NULL) || (NewString == NULL) || (FindTarget == NULL) @@ -2018,12 +2019,14 @@ CopyReplace( while (*SourceString != L'\0') { if (StrnCmp(SourceString, FindTarget, StrLen(FindTarget)) == 0) { SourceString += StrLen(FindTarget); - if ((StrSize(NewString) + (StrLen(ReplaceWith)*sizeof(CHAR16))) > NewSize) { + Size = StrSize(NewString); + if ((Size + (StrLen(ReplaceWith)*sizeof(CHAR16))) > NewSize) { return (EFI_BUFFER_TOO_SMALL); } StrCat(NewString, ReplaceWith); } else { - if (StrSize(NewString) + sizeof(CHAR16) > NewSize) { + Size = StrSize(NewString); + if (Size + sizeof(CHAR16) > NewSize) { return (EFI_BUFFER_TOO_SMALL); } StrnCat(NewString, SourceString, 1);