remove redirection command line updating from the shell core code.
add redirection command line updating to the redirection support function (UpdateStdInStdOutStdErr). add more user input verification to redirection. reduce user input verification from inside quoted parameters. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11460 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -1427,21 +1427,6 @@ RunCommand(
|
|||||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_REDIR), ShellInfoObject.HiiHandle);
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_REDIR), ShellInfoObject.HiiHandle);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//
|
|
||||||
// remove the < and/or > from the command line now
|
|
||||||
//
|
|
||||||
for (TempLocation3 = PostVariableCmdLine ; TempLocation3 != NULL && *TempLocation3 != CHAR_NULL ; TempLocation3++) {
|
|
||||||
if (*TempLocation3 == L'^') {
|
|
||||||
if (*(TempLocation3+1) == L'<' || *(TempLocation3+1) == L'>') {
|
|
||||||
CopyMem(TempLocation3, TempLocation3+1, StrSize(TempLocation3) - sizeof(TempLocation3[0]));
|
|
||||||
}
|
|
||||||
} else if (*TempLocation3 == L'>') {
|
|
||||||
*TempLocation3 = CHAR_NULL;
|
|
||||||
} else if ((*TempLocation3 == L'1' || *TempLocation3 == L'2')&&(*(TempLocation3+1) == L'>')) {
|
|
||||||
*TempLocation3 = CHAR_NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (PostVariableCmdLine[StrLen(PostVariableCmdLine)-1] == L' ') {
|
while (PostVariableCmdLine[StrLen(PostVariableCmdLine)-1] == L' ') {
|
||||||
PostVariableCmdLine[StrLen(PostVariableCmdLine)-1] = CHAR_NULL;
|
PostVariableCmdLine[StrLen(PostVariableCmdLine)-1] = CHAR_NULL;
|
||||||
}
|
}
|
||||||
|
@ -73,10 +73,6 @@ GetNextParameter(
|
|||||||
TempLoc++;
|
TempLoc++;
|
||||||
} else if (*TempLoc == L'^' && *(TempLoc+1) == L'\"') {
|
} else if (*TempLoc == L'^' && *(TempLoc+1) == L'\"') {
|
||||||
TempLoc++;
|
TempLoc++;
|
||||||
} else if (*TempLoc == L'^' && *(TempLoc+1) == L'|') {
|
|
||||||
TempLoc++;
|
|
||||||
} else if (*TempLoc == L'^') {
|
|
||||||
*TempLoc = L' ';
|
|
||||||
} else if (*TempLoc == L'\"') {
|
} else if (*TempLoc == L'\"') {
|
||||||
NextDelim = TempLoc;
|
NextDelim = TempLoc;
|
||||||
break;
|
break;
|
||||||
@ -447,6 +443,30 @@ IsUnicodeFile(
|
|||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Strips out quotes sections of a string.
|
||||||
|
|
||||||
|
All of the characters between quotes is replaced with spaces.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
StripQuotes (
|
||||||
|
IN OUT CHAR16 *TheString
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOLEAN RemoveNow;
|
||||||
|
|
||||||
|
for (RemoveNow = FALSE ; TheString != NULL && *TheString != CHAR_NULL ; TheString++) {
|
||||||
|
if (*TheString == L'^' && *(TheString + 1) == L'\"') {
|
||||||
|
TheString++;
|
||||||
|
} else if (*TheString == L'\"') {
|
||||||
|
RemoveNow = (BOOLEAN)!RemoveNow;
|
||||||
|
} else if (RemoveNow) {
|
||||||
|
*TheString = L' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Funcion will replace the current StdIn and StdOut in the ShellParameters protocol
|
Funcion will replace the current StdIn and StdOut in the ShellParameters protocol
|
||||||
structure by parsing NewCommandLine. The current values are returned to the
|
structure by parsing NewCommandLine. The current values are returned to the
|
||||||
@ -468,7 +488,7 @@ EFI_STATUS
|
|||||||
EFIAPI
|
EFIAPI
|
||||||
UpdateStdInStdOutStdErr(
|
UpdateStdInStdOutStdErr(
|
||||||
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
||||||
IN CONST CHAR16 *NewCommandLine,
|
IN CHAR16 *NewCommandLine,
|
||||||
OUT SHELL_FILE_HANDLE *OldStdIn,
|
OUT SHELL_FILE_HANDLE *OldStdIn,
|
||||||
OUT SHELL_FILE_HANDLE *OldStdOut,
|
OUT SHELL_FILE_HANDLE *OldStdOut,
|
||||||
OUT SHELL_FILE_HANDLE *OldStdErr,
|
OUT SHELL_FILE_HANDLE *OldStdErr,
|
||||||
@ -494,6 +514,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
UINTN Size;
|
UINTN Size;
|
||||||
CHAR16 TagBuffer[2];
|
CHAR16 TagBuffer[2];
|
||||||
SPLIT_LIST *Split;
|
SPLIT_LIST *Split;
|
||||||
|
CHAR16 *FirstLocation;
|
||||||
|
|
||||||
OutUnicode = TRUE;
|
OutUnicode = TRUE;
|
||||||
InUnicode = TRUE;
|
InUnicode = TRUE;
|
||||||
@ -507,6 +528,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
ErrAppend = FALSE;
|
ErrAppend = FALSE;
|
||||||
OutAppend = FALSE;
|
OutAppend = FALSE;
|
||||||
CommandLineCopy = NULL;
|
CommandLineCopy = NULL;
|
||||||
|
FirstLocation = (CHAR16*)(-1);
|
||||||
|
|
||||||
if (ShellParameters == NULL || SystemTableInfo == NULL || OldStdIn == NULL || OldStdOut == NULL || OldStdErr == NULL) {
|
if (ShellParameters == NULL || SystemTableInfo == NULL || OldStdIn == NULL || OldStdOut == NULL || OldStdErr == NULL) {
|
||||||
return (EFI_INVALID_PARAMETER);
|
return (EFI_INVALID_PARAMETER);
|
||||||
@ -530,6 +552,8 @@ UpdateStdInStdOutStdErr(
|
|||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
Split = NULL;
|
Split = NULL;
|
||||||
|
|
||||||
|
StripQuotes(CommandLineCopy);
|
||||||
|
|
||||||
if (!IsListEmpty(&ShellInfoObject.SplitList.Link)) {
|
if (!IsListEmpty(&ShellInfoObject.SplitList.Link)) {
|
||||||
Split = (SPLIT_LIST*)GetFirstNode(&ShellInfoObject.SplitList.Link);
|
Split = (SPLIT_LIST*)GetFirstNode(&ShellInfoObject.SplitList.Link);
|
||||||
if (Split != NULL && Split->SplitStdIn != NULL) {
|
if (Split != NULL && Split->SplitStdIn != NULL) {
|
||||||
@ -541,6 +565,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>>v ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>>v ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 12, L' ');
|
SetMem16(CommandLineWalker, 12, L' ');
|
||||||
StdErrVarName = CommandLineWalker += 6;
|
StdErrVarName = CommandLineWalker += 6;
|
||||||
ErrAppend = TRUE;
|
ErrAppend = TRUE;
|
||||||
@ -549,6 +574,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>v ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>v ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 12, L' ');
|
SetMem16(CommandLineWalker, 12, L' ');
|
||||||
StdOutVarName = CommandLineWalker += 6;
|
StdOutVarName = CommandLineWalker += 6;
|
||||||
OutAppend = TRUE;
|
OutAppend = TRUE;
|
||||||
@ -556,6 +582,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
Status = EFI_NOT_FOUND;
|
Status = EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
} else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>v ")) != NULL) {
|
} else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>v ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 10, L' ');
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
StdOutVarName = CommandLineWalker += 5;
|
StdOutVarName = CommandLineWalker += 5;
|
||||||
OutAppend = TRUE;
|
OutAppend = TRUE;
|
||||||
@ -563,6 +590,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
Status = EFI_NOT_FOUND;
|
Status = EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
} else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >v ")) != NULL) {
|
} else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >v ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 8, L' ');
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
StdOutVarName = CommandLineWalker += 4;
|
StdOutVarName = CommandLineWalker += 4;
|
||||||
OutAppend = FALSE;
|
OutAppend = FALSE;
|
||||||
@ -571,6 +599,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>a ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 12, L' ');
|
SetMem16(CommandLineWalker, 12, L' ');
|
||||||
StdOutFileName = CommandLineWalker += 6;
|
StdOutFileName = CommandLineWalker += 6;
|
||||||
OutAppend = TRUE;
|
OutAppend = TRUE;
|
||||||
@ -580,6 +609,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>> ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>> ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 10, L' ');
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -592,6 +622,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >> ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >> ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 8, L' ');
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -604,6 +635,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>a ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 10, L' ');
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -617,6 +649,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>a ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 10, L' ');
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -630,6 +663,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >a ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 8, L' ');
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -643,6 +677,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>> ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>> ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 10, L' ');
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdErrFileName != NULL) {
|
if (StdErrFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -656,6 +691,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>v ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>v ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 10, L' ');
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdErrVarName != NULL) {
|
if (StdErrVarName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -668,6 +704,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>v ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>v ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 10, L' ');
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdOutVarName != NULL) {
|
if (StdOutVarName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -680,6 +717,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>a ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 10, L' ');
|
SetMem16(CommandLineWalker, 10, L' ');
|
||||||
if (StdErrFileName != NULL) {
|
if (StdErrFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -693,6 +731,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2> ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2> ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 8, L' ');
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdErrFileName != NULL) {
|
if (StdErrFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -706,6 +745,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1> ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1> ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 8, L' ');
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -719,6 +759,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" > ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" > ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 6, L' ');
|
SetMem16(CommandLineWalker, 6, L' ');
|
||||||
if (StdOutFileName != NULL) {
|
if (StdOutFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -732,6 +773,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" < ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" < ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 6, L' ');
|
SetMem16(CommandLineWalker, 6, L' ');
|
||||||
if (StdInFileName != NULL) {
|
if (StdInFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -743,6 +785,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <a ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <a ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 8, L' ');
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdInFileName != NULL) {
|
if (StdInFileName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -755,6 +798,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <v ")) != NULL) {
|
if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <v ")) != NULL) {
|
||||||
|
FirstLocation = MIN(CommandLineWalker, FirstLocation);
|
||||||
SetMem16(CommandLineWalker, 8, L' ');
|
SetMem16(CommandLineWalker, 8, L' ');
|
||||||
if (StdInVarName != NULL) {
|
if (StdInVarName != NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
@ -766,6 +810,12 @@ UpdateStdInStdOutStdErr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FirstLocation != (CHAR16*)(-1)
|
||||||
|
&& ((UINTN)(FirstLocation - CommandLineCopy) < StrLen(NewCommandLine))
|
||||||
|
){
|
||||||
|
*(NewCommandLine + (UINTN)(FirstLocation - CommandLineCopy)) = CHAR_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
if (StdErrFileName != NULL && (CommandLineWalker = StrStr(StdErrFileName, L" ")) != NULL) {
|
if (StdErrFileName != NULL && (CommandLineWalker = StrStr(StdErrFileName, L" ")) != NULL) {
|
||||||
CommandLineWalker[0] = CHAR_NULL;
|
CommandLineWalker[0] = CHAR_NULL;
|
||||||
@ -786,14 +836,11 @@ UpdateStdInStdOutStdErr(
|
|||||||
CommandLineWalker[0] = CHAR_NULL;
|
CommandLineWalker[0] = CHAR_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Verify not the same and not duplicating something from a split
|
|
||||||
//
|
|
||||||
if (
|
if (
|
||||||
//
|
//
|
||||||
// Check that no 2 filenames are the same
|
// Check that no 2 filenames are the same
|
||||||
//
|
//
|
||||||
(StdErrFileName != NULL && StdOutFileName!= NULL && StringNoCaseCompare(&StdErrFileName, &StdOutFileName) == 0)
|
(StdErrFileName != NULL && StdOutFileName!= NULL && StringNoCaseCompare(&StdErrFileName, &StdOutFileName) == 0)
|
||||||
||(StdErrFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdErrFileName, &StdInFileName ) == 0)
|
||(StdErrFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdErrFileName, &StdInFileName ) == 0)
|
||||||
||(StdOutFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdOutFileName, &StdInFileName ) == 0)
|
||(StdOutFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdOutFileName, &StdInFileName ) == 0)
|
||||||
//
|
//
|
||||||
@ -814,11 +861,6 @@ UpdateStdInStdOutStdErr(
|
|||||||
||(StdOutFileName != NULL && StdOutVarName != NULL)
|
||(StdOutFileName != NULL && StdOutVarName != NULL)
|
||||||
||(StdInFileName != NULL && StdInVarName != NULL)
|
||(StdInFileName != NULL && StdInVarName != NULL)
|
||||||
//
|
//
|
||||||
// There should not be extra > or <
|
|
||||||
//
|
|
||||||
||(StrStr(CommandLineCopy, L"<") != NULL)
|
|
||||||
||(StrStr(CommandLineCopy, L">") != NULL)
|
|
||||||
//
|
|
||||||
// Check for no volatile environment variables
|
// Check for no volatile environment variables
|
||||||
//
|
//
|
||||||
||(StdErrVarName != NULL && !IsVolatileEnv(StdErrVarName))
|
||(StdErrVarName != NULL && !IsVolatileEnv(StdErrVarName))
|
||||||
@ -837,7 +879,7 @@ UpdateStdInStdOutStdErr(
|
|||||||
||(StdErrFileName != NULL && !ErrUnicode && ErrAppend && (!EFI_ERROR(ShellFileExists(StdErrFileName)) && !EFI_ERROR(IsUnicodeFile(StdErrFileName))))
|
||(StdErrFileName != NULL && !ErrUnicode && ErrAppend && (!EFI_ERROR(ShellFileExists(StdErrFileName)) && !EFI_ERROR(IsUnicodeFile(StdErrFileName))))
|
||||||
){
|
){
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
} else {
|
} else if (!EFI_ERROR(Status)){
|
||||||
//
|
//
|
||||||
// Open the Std<Whatever> and we should not have conflicts here...
|
// Open the Std<Whatever> and we should not have conflicts here...
|
||||||
//
|
//
|
||||||
|
@ -132,7 +132,7 @@ typedef struct {
|
|||||||
structure by parsing NewCommandLine. The current values are returned to the
|
structure by parsing NewCommandLine. The current values are returned to the
|
||||||
user.
|
user.
|
||||||
|
|
||||||
If OldStdIn or OldStdOut is NULL then that value is not returned.
|
This will also update the system table.
|
||||||
|
|
||||||
@param[in,out] ShellParameters Pointer to parameter structure to modify.
|
@param[in,out] ShellParameters Pointer to parameter structure to modify.
|
||||||
@param[in] NewCommandLine The new command line to parse and use.
|
@param[in] NewCommandLine The new command line to parse and use.
|
||||||
@ -148,7 +148,7 @@ EFI_STATUS
|
|||||||
EFIAPI
|
EFIAPI
|
||||||
UpdateStdInStdOutStdErr(
|
UpdateStdInStdOutStdErr(
|
||||||
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
|
||||||
IN CONST CHAR16 *NewCommandLine,
|
IN CHAR16 *NewCommandLine,
|
||||||
OUT SHELL_FILE_HANDLE *OldStdIn,
|
OUT SHELL_FILE_HANDLE *OldStdIn,
|
||||||
OUT SHELL_FILE_HANDLE *OldStdOut,
|
OUT SHELL_FILE_HANDLE *OldStdOut,
|
||||||
OUT SHELL_FILE_HANDLE *OldStdErr,
|
OUT SHELL_FILE_HANDLE *OldStdErr,
|
||||||
|
Reference in New Issue
Block a user