prevents "" from being the result of trying to open the root of a drive.

more input validation on vol command.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11444 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jcarsey 2011-03-28 21:49:17 +00:00
parent 590c3cb14a
commit e35b531794
2 changed files with 27 additions and 5 deletions

View File

@ -585,7 +585,11 @@ EfiShellGetDevicePathFromFilePath(
//
// build the full device path
//
DevicePathForReturn = FileDevicePath(Handle, Path+StrLen(MapName)+1);
if (*(Path+StrLen(MapName)+1) == CHAR_NULL) {
DevicePathForReturn = FileDevicePath(Handle, L"\\");
} else {
DevicePathForReturn = FileDevicePath(Handle, Path+StrLen(MapName)+1);
}
FreePool(MapName);
if (DevicePathCopyForFree != NULL) {

View File

@ -108,13 +108,24 @@ HandleVol(
}
}
SysInfo = AllocateZeroPool(SysInfoSize);
SysInfoSize = 0;
SysInfo = NULL;
Status = EfiFpHandle->GetInfo(
EfiFpHandle,
&gEfiFileSystemInfoGuid,
&SysInfoSize,
SysInfo);
if (Status == EFI_BUFFER_TOO_SMALL) {
SysInfo = AllocateZeroPool(SysInfoSize);
Status = EfiFpHandle->GetInfo(
EfiFpHandle,
&gEfiFileSystemInfoGuid,
&SysInfoSize,
SysInfo);
}
gEfiShellProtocol->CloseFile(ShellFileHandle);
//
@ -164,6 +175,7 @@ ShellCommandRunVol (
CONST CHAR16 *CurDir;
BOOLEAN DeleteMode;
CHAR16 *FullPath;
CHAR16 *TempSpot;
UINTN Length;
Length = 0;
@ -220,10 +232,16 @@ ShellCommandRunVol (
}
}
if (PathName != NULL) {
StrnCatGrow(&FullPath, &Length, PathName, StrStr(PathName, L"\\")==NULL?0:StrStr(PathName, L"\\")-PathName+1);
if (StrStr(FullPath, L":\\") == NULL) {
StrnCatGrow(&FullPath, &Length, L":\\", 0);
TempSpot = StrStr(PathName, L":");
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
TempSpot = StrStr(PathName, L"\\");
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
StrnCatGrow(&FullPath, &Length, PathName, 0);
StrnCatGrow(&FullPath, &Length, L":\\", 0);
DeleteMode = ShellCommandLineGetFlag(Package, L"-d");
if (DeleteMode && ShellCommandLineGetFlag(Package, L"-n")) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle);