continue;\r
}\r
\r
- ShellInfoObject.ShellInitSettings.FileName = AllocateZeroPool(StrSize(CurrentArg));\r
+ ShellInfoObject.ShellInitSettings.FileName = AllocateCopyPool(StrSize(CurrentArg), CurrentArg);\r
if (ShellInfoObject.ShellInitSettings.FileName == NULL) {\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
// We found `file-name`.\r
//\r
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoStartup = 1;\r
-\r
- StrCpy (ShellInfoObject.ShellInitSettings.FileName, CurrentArg);\r
LoopVar++;\r
\r
// Add `file-name-options`\r
if (FileStringPath == NULL) {\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
- StrCpy(FileStringPath, ShellInfoObject.ShellInitSettings.FileName);\r
+ StrnCpy(FileStringPath, ShellInfoObject.ShellInitSettings.FileName, NewSize/sizeof(CHAR16) -1);\r
if (ShellInfoObject.ShellInitSettings.FileOptions != NULL) {\r
- StrCat(FileStringPath, L" ");\r
- StrCat(FileStringPath, ShellInfoObject.ShellInitSettings.FileOptions);\r
+ StrnCat(FileStringPath, L" ", NewSize/sizeof(CHAR16) - StrLen(FileStringPath) -1);\r
+ StrnCat(FileStringPath, ShellInfoObject.ShellInitSettings.FileOptions, NewSize/sizeof(CHAR16) - StrLen(FileStringPath) -1);\r
}\r
Status = RunCommand(FileStringPath, ExitStatus);\r
FreePool(FileStringPath);\r
\r
Node = AllocateZeroPool(sizeof(BUFFER_LIST));\r
ASSERT(Node != NULL);\r
- Node->Buffer = AllocateZeroPool(StrSize(Buffer));\r
+ Node->Buffer = AllocateCopyPool(StrSize(Buffer), Buffer);\r
ASSERT(Node->Buffer != NULL);\r
- StrCpy(Node->Buffer, Buffer);\r
\r
InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);\r
}\r
return (EFI_SUCCESS);\r
}\r
FreePool(*CommandString);\r
- *CommandString = AllocateZeroPool(StrSize(NewString));\r
+ *CommandString = AllocateCopyPool(StrSize(NewString), NewString);\r
if (*CommandString == NULL) {\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
- StrCpy(*CommandString, NewString);\r
return (EFI_SUCCESS);\r
}\r
\r
//\r
// now do the replacements...\r
//\r
- NewCommandLine1 = AllocateZeroPool(NewSize);\r
+ NewCommandLine1 = AllocateCopyPool(NewSize, OriginalCommandLine);\r
NewCommandLine2 = AllocateZeroPool(NewSize);\r
ItemTemp = AllocateZeroPool(ItemSize+(2*sizeof(CHAR16)));\r
if (NewCommandLine1 == NULL || NewCommandLine2 == NULL || ItemTemp == NULL) {\r
SHELL_FREE_NON_NULL(ItemTemp);\r
return (NULL);\r
}\r
- StrCpy(NewCommandLine1, OriginalCommandLine);\r
for (MasterEnvList = EfiShellGetEnv(NULL)\r
- ; MasterEnvList != NULL && *MasterEnvList != CHAR_NULL //&& *(MasterEnvList+1) != CHAR_NULL\r
+ ; MasterEnvList != NULL && *MasterEnvList != CHAR_NULL\r
; MasterEnvList += StrLen(MasterEnvList) + 1\r
){\r
- StrCpy(ItemTemp, L"%");\r
- StrCat(ItemTemp, MasterEnvList);\r
- StrCat(ItemTemp, L"%");\r
+ *ItemTemp = L'%';\r
+ StrnCat(ItemTemp, MasterEnvList, ((ItemSize+(2*sizeof(CHAR16)))/sizeof(CHAR16))-1 - StrLen(ItemTemp));\r
+ StrnCat(ItemTemp, L"%", ((ItemSize+(2*sizeof(CHAR16)))/sizeof(CHAR16))-1 - StrLen(ItemTemp));\r
ShellCopySearchAndReplace(NewCommandLine1, NewCommandLine2, NewSize, ItemTemp, EfiShellGetEnv(MasterEnvList), TRUE, FALSE);\r
- StrCpy(NewCommandLine1, NewCommandLine2);\r
+ StrnCpy(NewCommandLine1, NewCommandLine2, NewSize/sizeof(CHAR16)-1);\r
}\r
if (CurrentScriptFile != NULL) {\r
for (AliasListNode = (ALIAS_LIST*)GetFirstNode(&CurrentScriptFile->SubstList)\r
; AliasListNode = (ALIAS_LIST*)GetNextNode(&CurrentScriptFile->SubstList, &AliasListNode->Link)\r
){\r
ShellCopySearchAndReplace(NewCommandLine1, NewCommandLine2, NewSize, AliasListNode->Alias, AliasListNode->CommandString, TRUE, FALSE);\r
- StrCpy(NewCommandLine1, NewCommandLine2);\r
+ StrnCpy(NewCommandLine1, NewCommandLine2, NewSize/sizeof(CHAR16)-1);\r
}\r
\r
//\r
// Now cleanup any straggler intentionally ignored "%" characters\r
//\r
ShellCopySearchAndReplace(NewCommandLine1, NewCommandLine2, NewSize, L"^%", L"%", TRUE, FALSE);\r
- StrCpy(NewCommandLine1, NewCommandLine2);\r
+ StrnCpy(NewCommandLine1, NewCommandLine2, NewSize/sizeof(CHAR16)-1);\r
\r
FreePool(NewCommandLine2);\r
FreePool(ItemTemp);\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
TempWalker = (CHAR16*)Temp;\r
- GetNextParameter(&TempWalker, &FirstParameter);\r
+ GetNextParameter(&TempWalker, &FirstParameter, StrSize(CmdLine));\r
\r
if (GetOperationType(FirstParameter) == Unknown_Invalid) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);\r
Walker = *CmdLine;\r
while(Walker != NULL && *Walker != CHAR_NULL) {\r
LastWalker = Walker;\r
- GetNextParameter(&Walker, &CurrentParameter);\r
+ GetNextParameter(&Walker, &CurrentParameter, StrSize(*CmdLine));\r
if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {\r
LastWalker[0] = L' ';\r
LastWalker[1] = L' ';\r
Status = EFI_OUT_OF_RESOURCES;\r
break;\r
}\r
- StrCpy(NewCommandLine, L"help ");\r
- StrCat(NewCommandLine, *CmdLine);\r
+\r
+ //\r
+ // We know the space is sufficient since we just calculated it.\r
+ //\r
+ StrnCpy(NewCommandLine, L"help ", 5);\r
+ StrnCat(NewCommandLine, *CmdLine, StrLen(*CmdLine));\r
SHELL_FREE_NON_NULL(*CmdLine);\r
*CmdLine = NewCommandLine;\r
break;\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
TempWalker = CleanOriginal;\r
- GetNextParameter(&TempWalker, &FirstParameter);\r
+ GetNextParameter(&TempWalker, &FirstParameter, StrSize(CleanOriginal));\r
\r
//\r
// Depending on the first parameter we change the behavior\r
; // conditional increment in the body of the loop\r
){\r
ASSERT(CommandLine2 != NULL);\r
- StrCpy(CommandLine2, NewScriptFile->CurrentCommand->Cl);\r
+ StrnCpy(CommandLine2, NewScriptFile->CurrentCommand->Cl, PcdGet16(PcdShellPrintBufferSize)/sizeof(CHAR16)-1);\r
\r
//\r
// NULL out comments\r
//\r
// Due to variability in starting the find and replace action we need to have both buffers the same.\r
//\r
- StrCpy(CommandLine, CommandLine2);\r
+ StrnCpy(CommandLine, CommandLine2, PcdGet16(PcdShellPrintBufferSize)/sizeof(CHAR16)-1);\r
\r
//\r
// Remove the %0 to %9 from the command line (if we have some arguments)\r
if (NewScriptFile->Argv != NULL) {\r
switch (NewScriptFile->Argc) {\r
default:\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%9", NewScriptFile->Argv[9], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%9", NewScriptFile->Argv[9], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 9:\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%8", NewScriptFile->Argv[8], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%8", NewScriptFile->Argv[8], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 8:\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%7", NewScriptFile->Argv[7], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%7", NewScriptFile->Argv[7], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 7:\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%6", NewScriptFile->Argv[6], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%6", NewScriptFile->Argv[6], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 6:\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%5", NewScriptFile->Argv[5], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%5", NewScriptFile->Argv[5], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 5:\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%4", NewScriptFile->Argv[4], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%4", NewScriptFile->Argv[4], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 4:\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%3", NewScriptFile->Argv[3], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%3", NewScriptFile->Argv[3], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 3:\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%2", NewScriptFile->Argv[2], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%2", NewScriptFile->Argv[2], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 2:\r
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%1", NewScriptFile->Argv[1], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%1", NewScriptFile->Argv[1], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
case 1:\r
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%0", NewScriptFile->Argv[0], FALSE, TRUE);\r
+ Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%0", NewScriptFile->Argv[0], FALSE, FALSE);\r
ASSERT_EFI_ERROR(Status);\r
break;\r
case 0:\r
Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PcdGet16 (PcdShellPrintBufferSize), L"%8", L"\"\"", FALSE, FALSE);\r
Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PcdGet16 (PcdShellPrintBufferSize), L"%9", L"\"\"", FALSE, FALSE);\r
\r
- StrCpy(CommandLine2, CommandLine);\r
+ StrnCpy(CommandLine2, CommandLine, PcdGet16(PcdShellPrintBufferSize)/sizeof(CHAR16)-1);\r
\r
LastCommand = NewScriptFile->CurrentCommand;\r
\r