mirror of https://github.com/acidanthera/audk.git
fixes for NULL verification.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11125 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
eca37a3101
commit
c154b99708
|
@ -183,7 +183,7 @@ GetEnvironmentVariableList(
|
||||||
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val);
|
Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status) && VarList != NULL) {
|
||||||
VarList->Key = AllocatePool(StrSize(VariableName));
|
VarList->Key = AllocatePool(StrSize(VariableName));
|
||||||
if (VarList->Key == NULL) {
|
if (VarList->Key == NULL) {
|
||||||
SHELL_FREE_NON_NULL(VarList->Val);
|
SHELL_FREE_NON_NULL(VarList->Val);
|
||||||
|
|
|
@ -907,75 +907,46 @@ InternalOpenFileDevicePath(
|
||||||
|
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
Handle1 = ConvertShellHandleToEfiFileProtocol(ShellHandle);
|
Handle1 = ConvertShellHandleToEfiFileProtocol(ShellHandle);
|
||||||
//
|
if (Handle1 != NULL) {
|
||||||
// chop off the begining part before the file system part...
|
|
||||||
//
|
|
||||||
///@todo BlockIo?
|
|
||||||
Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid,
|
|
||||||
&DevicePath,
|
|
||||||
&Handle);
|
|
||||||
if (!EFI_ERROR(Status)) {
|
|
||||||
//
|
//
|
||||||
// To access as a file system, the file path should only
|
// chop off the begining part before the file system part...
|
||||||
// contain file path components. Follow the file path nodes
|
|
||||||
// and find the target file
|
|
||||||
//
|
//
|
||||||
for ( FilePathNode = (FILEPATH_DEVICE_PATH *)DevicePath
|
///@todo BlockIo?
|
||||||
; !IsDevicePathEnd (&FilePathNode->Header)
|
Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid,
|
||||||
; FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header)
|
&DevicePath,
|
||||||
){
|
&Handle);
|
||||||
SHELL_FREE_NON_NULL(AlignedNode);
|
if (!EFI_ERROR(Status)) {
|
||||||
AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePathNode), FilePathNode);
|
|
||||||
//
|
//
|
||||||
// For file system access each node should be a file path component
|
// To access as a file system, the file path should only
|
||||||
|
// contain file path components. Follow the file path nodes
|
||||||
|
// and find the target file
|
||||||
//
|
//
|
||||||
if (DevicePathType (&FilePathNode->Header) != MEDIA_DEVICE_PATH ||
|
for ( FilePathNode = (FILEPATH_DEVICE_PATH *)DevicePath
|
||||||
DevicePathSubType (&FilePathNode->Header) != MEDIA_FILEPATH_DP
|
; !IsDevicePathEnd (&FilePathNode->Header)
|
||||||
) {
|
; FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header)
|
||||||
Status = EFI_UNSUPPORTED;
|
){
|
||||||
break;
|
SHELL_FREE_NON_NULL(AlignedNode);
|
||||||
}
|
AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePathNode), FilePathNode);
|
||||||
|
//
|
||||||
//
|
// For file system access each node should be a file path component
|
||||||
// Open this file path node
|
//
|
||||||
//
|
if (DevicePathType (&FilePathNode->Header) != MEDIA_DEVICE_PATH ||
|
||||||
Handle2 = Handle1;
|
DevicePathSubType (&FilePathNode->Header) != MEDIA_FILEPATH_DP
|
||||||
Handle1 = NULL;
|
) {
|
||||||
|
Status = EFI_UNSUPPORTED;
|
||||||
//
|
break;
|
||||||
// if this is the last node in the DevicePath always create (if that was requested).
|
}
|
||||||
//
|
|
||||||
if (IsDevicePathEnd ((NextDevicePathNode (&FilePathNode->Header)))) {
|
|
||||||
Status = Handle2->Open (
|
|
||||||
Handle2,
|
|
||||||
&Handle1,
|
|
||||||
AlignedNode->PathName,
|
|
||||||
OpenMode,
|
|
||||||
Attributes
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// This is not the last node and we dont want to 'create' existing
|
// Open this file path node
|
||||||
// directory entries...
|
|
||||||
//
|
//
|
||||||
|
Handle2 = Handle1;
|
||||||
|
Handle1 = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
// open without letting it create
|
// if this is the last node in the DevicePath always create (if that was requested).
|
||||||
// prevents error on existing files/directories
|
|
||||||
//
|
//
|
||||||
Status = Handle2->Open (
|
if (IsDevicePathEnd ((NextDevicePathNode (&FilePathNode->Header)))) {
|
||||||
Handle2,
|
|
||||||
&Handle1,
|
|
||||||
AlignedNode->PathName,
|
|
||||||
OpenMode &~EFI_FILE_MODE_CREATE,
|
|
||||||
Attributes
|
|
||||||
);
|
|
||||||
//
|
|
||||||
// if above failed now open and create the 'item'
|
|
||||||
// if OpenMode EFI_FILE_MODE_CREATE bit was on (but disabled above)
|
|
||||||
//
|
|
||||||
if ((EFI_ERROR (Status)) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)) {
|
|
||||||
Status = Handle2->Open (
|
Status = Handle2->Open (
|
||||||
Handle2,
|
Handle2,
|
||||||
&Handle1,
|
&Handle1,
|
||||||
|
@ -983,20 +954,51 @@ InternalOpenFileDevicePath(
|
||||||
OpenMode,
|
OpenMode,
|
||||||
Attributes
|
Attributes
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
//
|
|
||||||
// Close the last node
|
|
||||||
//
|
|
||||||
ShellInfoObject.NewEfiShellProtocol->CloseFile (Handle2);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// If there's been an error, stop
|
// This is not the last node and we dont want to 'create' existing
|
||||||
//
|
// directory entries...
|
||||||
if (EFI_ERROR (Status)) {
|
//
|
||||||
break;
|
|
||||||
}
|
//
|
||||||
} // for loop
|
// open without letting it create
|
||||||
|
// prevents error on existing files/directories
|
||||||
|
//
|
||||||
|
Status = Handle2->Open (
|
||||||
|
Handle2,
|
||||||
|
&Handle1,
|
||||||
|
AlignedNode->PathName,
|
||||||
|
OpenMode &~EFI_FILE_MODE_CREATE,
|
||||||
|
Attributes
|
||||||
|
);
|
||||||
|
//
|
||||||
|
// if above failed now open and create the 'item'
|
||||||
|
// if OpenMode EFI_FILE_MODE_CREATE bit was on (but disabled above)
|
||||||
|
//
|
||||||
|
if ((EFI_ERROR (Status)) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)) {
|
||||||
|
Status = Handle2->Open (
|
||||||
|
Handle2,
|
||||||
|
&Handle1,
|
||||||
|
AlignedNode->PathName,
|
||||||
|
OpenMode,
|
||||||
|
Attributes
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Close the last node
|
||||||
|
//
|
||||||
|
ShellInfoObject.NewEfiShellProtocol->CloseFile (Handle2);
|
||||||
|
|
||||||
|
//
|
||||||
|
// If there's been an error, stop
|
||||||
|
//
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} // for loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SHELL_FREE_NON_NULL(AlignedNode);
|
SHELL_FREE_NON_NULL(AlignedNode);
|
||||||
|
@ -2001,7 +2003,7 @@ ShellSearchHandle(
|
||||||
ShellInfoNode->FullName = NewFullName;
|
ShellInfoNode->FullName = NewFullName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Directory && !EFI_ERROR(Status)){
|
if (Directory && !EFI_ERROR(Status) && ShellInfoNode->FullName != NULL && ShellInfoNode->FileName != NULL){
|
||||||
//
|
//
|
||||||
// should be a directory
|
// should be a directory
|
||||||
//
|
//
|
||||||
|
@ -2015,7 +2017,6 @@ ShellSearchHandle(
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
ASSERT_EFI_ERROR(Status);
|
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -679,18 +679,19 @@ PerformMappingDelete(
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
if (HandleBuffer != NULL) {
|
||||||
// Get the map name(s) for each one.
|
//
|
||||||
//
|
// Get the map name(s) for each one.
|
||||||
for ( LoopVar = 0
|
//
|
||||||
; LoopVar < BufferSize / sizeof(EFI_HANDLE)
|
for ( LoopVar = 0
|
||||||
; LoopVar ++
|
; LoopVar < BufferSize / sizeof(EFI_HANDLE)
|
||||||
){
|
; LoopVar ++
|
||||||
if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
|
){
|
||||||
Deleted = TRUE;
|
if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
|
||||||
|
Deleted = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Look up all BlockIo in the platform
|
// Look up all BlockIo in the platform
|
||||||
//
|
//
|
||||||
|
@ -718,30 +719,32 @@ PerformMappingDelete(
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
if (HandleBuffer != NULL) {
|
||||||
// Get the map name(s) for each one.
|
|
||||||
//
|
|
||||||
for ( LoopVar = 0
|
|
||||||
; LoopVar < BufferSize / sizeof(EFI_HANDLE)
|
|
||||||
; LoopVar ++
|
|
||||||
){
|
|
||||||
//
|
//
|
||||||
// Skip any that were already done...
|
// Get the map name(s) for each one.
|
||||||
//
|
//
|
||||||
if (gBS->OpenProtocol(
|
for ( LoopVar = 0
|
||||||
HandleBuffer[LoopVar],
|
; LoopVar < BufferSize / sizeof(EFI_HANDLE)
|
||||||
&gEfiDevicePathProtocolGuid,
|
; LoopVar ++
|
||||||
NULL,
|
){
|
||||||
gImageHandle,
|
//
|
||||||
NULL,
|
// Skip any that were already done...
|
||||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {
|
//
|
||||||
continue;
|
if (gBS->OpenProtocol(
|
||||||
}
|
HandleBuffer[LoopVar],
|
||||||
if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
|
&gEfiDevicePathProtocolGuid,
|
||||||
Deleted = TRUE;
|
NULL,
|
||||||
|
gImageHandle,
|
||||||
|
NULL,
|
||||||
|
EFI_OPEN_PROTOCOL_TEST_PROTOCOL) == EFI_SUCCESS) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (PerformSingleMappingDelete(Specific,HandleBuffer[LoopVar]) == SHELL_SUCCESS) {
|
||||||
|
Deleted = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FreePool(HandleBuffer);
|
SHELL_FREE_NON_NULL(HandleBuffer);
|
||||||
if (!Deleted) {
|
if (!Deleted) {
|
||||||
return (EFI_NOT_FOUND);
|
return (EFI_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue