ShellPkg: UefiShellCommandLib: CodeQL Fixes
Includes changes across the module for the following CodeQL rules: - cpp/comparison-with-wider-type - cpp/overflow-buffer - cpp/redundant-null-check-param - cpp/uselesstest Co-authored-by: Taylor Beebe <taylor.d.beebe@gmail.com> Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
This commit is contained in:
parent
1d64506f05
commit
c80c222198
|
@ -1404,6 +1404,10 @@ GetHIDevicePath (
|
||||||
NonHIDevicePathNodeCount = 0;
|
NonHIDevicePathNodeCount = 0;
|
||||||
|
|
||||||
HIDevicePath = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));
|
HIDevicePath = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));
|
||||||
|
if (HIDevicePath == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SetDevicePathEndNode (HIDevicePath);
|
SetDevicePathEndNode (HIDevicePath);
|
||||||
|
|
||||||
Node.DevPath.Type = END_DEVICE_PATH_TYPE;
|
Node.DevPath.Type = END_DEVICE_PATH_TYPE;
|
||||||
|
|
|
@ -1142,7 +1142,7 @@ DeleteScriptFileStruct (
|
||||||
IN SCRIPT_FILE *Script
|
IN SCRIPT_FILE *Script
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT8 LoopVar;
|
UINTN LoopVar;
|
||||||
|
|
||||||
if (Script == NULL) {
|
if (Script == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -1263,6 +1263,10 @@ ShellCommandCreateNewMappingName (
|
||||||
String = NULL;
|
String = NULL;
|
||||||
|
|
||||||
String = AllocateZeroPool (PcdGet8 (PcdShellMapNameLength) * sizeof (String[0]));
|
String = AllocateZeroPool (PcdGet8 (PcdShellMapNameLength) * sizeof (String[0]));
|
||||||
|
if (String == NULL) {
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
UnicodeSPrint (
|
UnicodeSPrint (
|
||||||
String,
|
String,
|
||||||
PcdGet8 (PcdShellMapNameLength) * sizeof (String[0]),
|
PcdGet8 (PcdShellMapNameLength) * sizeof (String[0]),
|
||||||
|
@ -1459,7 +1463,13 @@ ShellCommandCreateInitialMappingsAndPaths (
|
||||||
//
|
//
|
||||||
PerformQuickSort (DevicePathList, Count, sizeof (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare);
|
PerformQuickSort (DevicePathList, Count, sizeof (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare);
|
||||||
|
|
||||||
if (!EFI_ERROR (ShellCommandConsistMappingInitialize (&ConsistMappingTable))) {
|
Status = ShellCommandConsistMappingInitialize (&ConsistMappingTable);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
SHELL_FREE_NON_NULL (HandleList);
|
||||||
|
SHELL_FREE_NON_NULL (DevicePathList);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Assign new Mappings to all...
|
// Assign new Mappings to all...
|
||||||
//
|
//
|
||||||
|
@ -1468,7 +1478,12 @@ ShellCommandCreateInitialMappingsAndPaths (
|
||||||
// Get default name first
|
// Get default name first
|
||||||
//
|
//
|
||||||
NewDefaultName = ShellCommandCreateNewMappingName (MappingTypeFileSystem);
|
NewDefaultName = ShellCommandCreateNewMappingName (MappingTypeFileSystem);
|
||||||
|
if (NewDefaultName == NULL) {
|
||||||
ASSERT (NewDefaultName != NULL);
|
ASSERT (NewDefaultName != NULL);
|
||||||
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Status = ShellCommandAddMapItemAndUpdatePath (NewDefaultName, DevicePathList[Count], 0, TRUE);
|
Status = ShellCommandAddMapItemAndUpdatePath (NewDefaultName, DevicePathList[Count], 0, TRUE);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
FreePool (NewDefaultName);
|
FreePool (NewDefaultName);
|
||||||
|
@ -1483,7 +1498,6 @@ ShellCommandCreateInitialMappingsAndPaths (
|
||||||
FreePool (NewConsistName);
|
FreePool (NewConsistName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ConsistMappingTable != NULL) {
|
if (ConsistMappingTable != NULL) {
|
||||||
ShellCommandConsistMappingUnInitialize (ConsistMappingTable);
|
ShellCommandConsistMappingUnInitialize (ConsistMappingTable);
|
||||||
|
@ -1561,7 +1575,13 @@ ShellCommandCreateInitialMappingsAndPaths (
|
||||||
// Get default name first
|
// Get default name first
|
||||||
//
|
//
|
||||||
NewDefaultName = ShellCommandCreateNewMappingName (MappingTypeBlockIo);
|
NewDefaultName = ShellCommandCreateNewMappingName (MappingTypeBlockIo);
|
||||||
|
if (NewDefaultName == NULL) {
|
||||||
ASSERT (NewDefaultName != NULL);
|
ASSERT (NewDefaultName != NULL);
|
||||||
|
SHELL_FREE_NON_NULL (HandleList);
|
||||||
|
SHELL_FREE_NON_NULL (DevicePathList);
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
Status = ShellCommandAddMapItemAndUpdatePath (NewDefaultName, DevicePathList[Count], 0, FALSE);
|
Status = ShellCommandAddMapItemAndUpdatePath (NewDefaultName, DevicePathList[Count], 0, FALSE);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
FreePool (NewDefaultName);
|
FreePool (NewDefaultName);
|
||||||
|
@ -1631,6 +1651,11 @@ ShellCommandUpdateMapping (
|
||||||
PerformQuickSort (DevicePathList, Count, sizeof (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare);
|
PerformQuickSort (DevicePathList, Count, sizeof (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare);
|
||||||
|
|
||||||
Status = ShellCommandConsistMappingInitialize (&ConsistMappingTable);
|
Status = ShellCommandConsistMappingInitialize (&ConsistMappingTable);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
SHELL_FREE_NON_NULL (HandleList);
|
||||||
|
SHELL_FREE_NON_NULL (DevicePathList);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Assign new Mappings to remainders
|
// Assign new Mappings to remainders
|
||||||
|
|
|
@ -691,6 +691,8 @@ ShellCommandRunFor (
|
||||||
|
|
||||||
TempString = AllocateZeroPool (50*sizeof (CHAR16));
|
TempString = AllocateZeroPool (50*sizeof (CHAR16));
|
||||||
if (TempString == NULL) {
|
if (TempString == NULL) {
|
||||||
|
SHELL_FREE_NON_NULL (ArgSet);
|
||||||
|
SHELL_FREE_NON_NULL (Info);
|
||||||
return (SHELL_OUT_OF_RESOURCES);
|
return (SHELL_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue