mirror of https://github.com/acidanthera/audk.git
rm - refine user input validation to prevent removal of CWD.
change colors of "set" command output. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11538 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
a49016b117
commit
eef1ed4638
|
@ -172,29 +172,53 @@ IsValidDeleteTarget(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CONST CHAR16 *TempLocation;
|
CONST CHAR16 *TempLocation;
|
||||||
CHAR16 *Temp2;
|
BOOLEAN RetVal;
|
||||||
|
CHAR16 *SearchString;
|
||||||
|
CHAR16 *Pattern;
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
|
|
||||||
|
if (Node == NULL || Node->FullName == NULL) {
|
||||||
|
return (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
TempLocation = StrStr(Node->FullName, L":");
|
TempLocation = StrStr(Node->FullName, L":");
|
||||||
if (StrLen(TempLocation) == 2) {
|
if (StrLen(TempLocation) <= 2) {
|
||||||
//
|
//
|
||||||
// Deleting the root directory is invalid.
|
// Deleting the root directory is invalid.
|
||||||
//
|
//
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
TempLocation = ShellGetCurrentDir(NULL);
|
|
||||||
Size = 0;
|
|
||||||
Temp2 = NULL;
|
|
||||||
StrnCatGrow(&Temp2, &Size, TempLocation, 0);
|
|
||||||
if (StrStr(Temp2, Node->FullName) != NULL) {
|
|
||||||
FreePool(Temp2);
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
FreePool(Temp2);
|
|
||||||
|
|
||||||
|
TempLocation = ShellGetCurrentDir(NULL);
|
||||||
|
if (TempLocation == NULL) {
|
||||||
|
//
|
||||||
|
// No working directory is specified so whatever is left is ok.
|
||||||
|
//
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pattern = NULL;
|
||||||
|
SearchString = NULL;
|
||||||
|
Size = 0;
|
||||||
|
Pattern = StrnCatGrow(&Pattern , NULL, TempLocation , 0);
|
||||||
|
SearchString = StrnCatGrow(&SearchString, &Size, Node->FullName, 0);
|
||||||
|
SearchString = StrnCatGrow(&SearchString, &Size, L"*", 0);
|
||||||
|
|
||||||
|
if (Pattern == NULL || SearchString == NULL) {
|
||||||
|
RetVal = FALSE;
|
||||||
|
} else {
|
||||||
|
RetVal = TRUE;
|
||||||
|
if (gUnicodeCollation->MetaiMatch(gUnicodeCollation, Pattern, SearchString)) {
|
||||||
|
RetVal = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SHELL_FREE_NON_NULL(Pattern );
|
||||||
|
SHELL_FREE_NON_NULL(SearchString);
|
||||||
|
|
||||||
|
return (RetVal);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Function for 'rm' command.
|
Function for 'rm' command.
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue