summaryrefslogtreecommitdiff
path: root/edk2/ShellPkg/Application
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2010-12-06 18:10:34 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2010-12-06 18:10:34 +0000
commit45c79bdafff779778e60529278e8c7164a4d08e8 (patch)
tree99c6bc17b6f8ea7ccd60e75382b75fcbc0a2fc85 /edk2/ShellPkg/Application
parentcf7ef0641475f8b7d1145e4e335468b71a2a6413 (diff)
fixes for NULL verification.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk@11125 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'edk2/ShellPkg/Application')
-rw-r--r--edk2/ShellPkg/Application/Shell/ShellEnvVar.c2
-rw-r--r--edk2/ShellPkg/Application/Shell/ShellProtocol.c145
2 files changed, 74 insertions, 73 deletions
diff --git a/edk2/ShellPkg/Application/Shell/ShellEnvVar.c b/edk2/ShellPkg/Application/Shell/ShellEnvVar.c
index f22fb705d..519181b56 100644
--- a/edk2/ShellPkg/Application/Shell/ShellEnvVar.c
+++ b/edk2/ShellPkg/Application/Shell/ShellEnvVar.c
@@ -183,7 +183,7 @@ GetEnvironmentVariableList(
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));
if (VarList->Key == NULL) {
SHELL_FREE_NON_NULL(VarList->Val);
diff --git a/edk2/ShellPkg/Application/Shell/ShellProtocol.c b/edk2/ShellPkg/Application/Shell/ShellProtocol.c
index 0f799786e..19759cbb2 100644
--- a/edk2/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/edk2/ShellPkg/Application/Shell/ShellProtocol.c
@@ -907,75 +907,46 @@ InternalOpenFileDevicePath(
if (!EFI_ERROR(Status)) {
Handle1 = ConvertShellHandleToEfiFileProtocol(ShellHandle);
- //
- // chop off the begining part before the file system part...
- //
- ///@todo BlockIo?
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid,
- &DevicePath,
- &Handle);
- if (!EFI_ERROR(Status)) {
+ if (Handle1 != NULL) {
//
- // 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
+ // chop off the begining part before the file system part...
//
- for ( FilePathNode = (FILEPATH_DEVICE_PATH *)DevicePath
- ; !IsDevicePathEnd (&FilePathNode->Header)
- ; FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header)
- ){
- SHELL_FREE_NON_NULL(AlignedNode);
- AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePathNode), FilePathNode);
- //
- // For file system access each node should be a file path component
- //
- if (DevicePathType (&FilePathNode->Header) != MEDIA_DEVICE_PATH ||
- DevicePathSubType (&FilePathNode->Header) != MEDIA_FILEPATH_DP
- ) {
- Status = EFI_UNSUPPORTED;
- break;
- }
-
- //
- // Open this file path node
- //
- Handle2 = Handle1;
- Handle1 = NULL;
-
+ ///@todo BlockIo?
+ Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid,
+ &DevicePath,
+ &Handle);
+ if (!EFI_ERROR(Status)) {
//
- // if this is the last node in the DevicePath always create (if that was requested).
+ // 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 (IsDevicePathEnd ((NextDevicePathNode (&FilePathNode->Header)))) {
- Status = Handle2->Open (
- Handle2,
- &Handle1,
- AlignedNode->PathName,
- OpenMode,
- Attributes
- );
- } else {
-
+ for ( FilePathNode = (FILEPATH_DEVICE_PATH *)DevicePath
+ ; !IsDevicePathEnd (&FilePathNode->Header)
+ ; FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header)
+ ){
+ SHELL_FREE_NON_NULL(AlignedNode);
+ AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePathNode), FilePathNode);
//
- // This is not the last node and we dont want to 'create' existing
- // directory entries...
+ // For file system access each node should be a file path component
//
+ if (DevicePathType (&FilePathNode->Header) != MEDIA_DEVICE_PATH ||
+ DevicePathSubType (&FilePathNode->Header) != MEDIA_FILEPATH_DP
+ ) {
+ Status = EFI_UNSUPPORTED;
+ break;
+ }
//
- // open without letting it create
- // prevents error on existing files/directories
+ // Open this file path node
//
- Status = Handle2->Open (
- Handle2,
- &Handle1,
- AlignedNode->PathName,
- OpenMode &~EFI_FILE_MODE_CREATE,
- Attributes
- );
+ Handle2 = Handle1;
+ Handle1 = NULL;
+
//
- // if above failed now open and create the 'item'
- // if OpenMode EFI_FILE_MODE_CREATE bit was on (but disabled above)
+ // if this is the last node in the DevicePath always create (if that was requested).
//
- if ((EFI_ERROR (Status)) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)) {
+ if (IsDevicePathEnd ((NextDevicePathNode (&FilePathNode->Header)))) {
Status = Handle2->Open (
Handle2,
&Handle1,
@@ -983,20 +954,51 @@ InternalOpenFileDevicePath(
OpenMode,
Attributes
);
+ } else {
+
+ //
+ // This is not the last node and we dont want to 'create' existing
+ // directory entries...
+ //
+
+ //
+ // 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);
+ //
+ // Close the last node
+ //
+ ShellInfoObject.NewEfiShellProtocol->CloseFile (Handle2);
- //
- // If there's been an error, stop
- //
- if (EFI_ERROR (Status)) {
- break;
- }
- } // for loop
+ //
+ // If there's been an error, stop
+ //
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ } // for loop
+ }
}
}
SHELL_FREE_NON_NULL(AlignedNode);
@@ -2001,7 +2003,7 @@ ShellSearchHandle(
ShellInfoNode->FullName = NewFullName;
}
}
- if (Directory && !EFI_ERROR(Status)){
+ if (Directory && !EFI_ERROR(Status) && ShellInfoNode->FullName != NULL && ShellInfoNode->FileName != NULL){
//
// should be a directory
//
@@ -2015,7 +2017,6 @@ ShellSearchHandle(
//
//
//
- ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
break;
}