diff options
Diffstat (limited to 'ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c')
-rw-r--r-- | ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c | 128 |
1 files changed, 102 insertions, 26 deletions
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index 781da4d..14f1725 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -4,6 +4,7 @@ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
(C) Copyright 2015-2021 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -299,6 +300,9 @@ LoadedImageProtocolDumpInformation ( SHELL_FREE_NON_NULL (Temp);
SHELL_FREE_NON_NULL (FileName);
+ if (RetVal == NULL) {
+ return NULL;
+ }
}
Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_LI_DUMP_MAIN), NULL);
@@ -309,24 +313,25 @@ LoadedImageProtocolDumpInformation ( PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);
DataType = ConvertMemoryType (LoadedImage->ImageDataType);
CodeType = ConvertMemoryType (LoadedImage->ImageCodeType);
-
- RetVal = CatSPrint (
- RetVal,
- Temp,
- LoadedImage->Revision,
- LoadedImage->ParentHandle,
- LoadedImage->SystemTable,
- LoadedImage->DeviceHandle,
- FilePath,
- PdbFileName,
- LoadedImage->LoadOptionsSize,
- LoadedImage->LoadOptions,
- LoadedImage->ImageBase,
- LoadedImage->ImageSize,
- CodeType,
- DataType,
- LoadedImage->Unload
- );
+ if ((PdbFileName != NULL) && (DataType != NULL) && (CodeType != NULL) && (FilePath != NULL)) {
+ RetVal = CatSPrint (
+ RetVal,
+ Temp,
+ LoadedImage->Revision,
+ LoadedImage->ParentHandle,
+ LoadedImage->SystemTable,
+ LoadedImage->DeviceHandle,
+ FilePath,
+ PdbFileName,
+ LoadedImage->LoadOptionsSize,
+ LoadedImage->LoadOptions,
+ LoadedImage->ImageBase,
+ LoadedImage->ImageSize,
+ CodeType,
+ DataType,
+ LoadedImage->Unload
+ );
+ }
SHELL_FREE_NON_NULL (Temp);
SHELL_FREE_NON_NULL (FilePath);
@@ -389,6 +394,10 @@ GraphicsOutputProtocolDumpInformation ( }
Fmt = ConvertPixelFormat (GraphicsOutput->Mode->Info->PixelFormat);
+ if (Fmt == NULL) {
+ SHELL_FREE_NON_NULL (Temp);
+ return NULL;
+ }
RetVal = CatSPrint (
NULL,
@@ -409,6 +418,9 @@ GraphicsOutputProtocolDumpInformation ( );
SHELL_FREE_NON_NULL (Temp);
+ if (RetVal == NULL) {
+ goto EXIT;
+ }
Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_GOP_RES_LIST_MAIN), NULL);
if (Temp == NULL) {
@@ -509,6 +521,9 @@ EdidDiscoveredProtocolDumpInformation ( RetVal = CatSPrint (NULL, Temp, EdidDiscovered->SizeOfEdid);
SHELL_FREE_NON_NULL (Temp);
+ if (RetVal == NULL) {
+ return NULL;
+ }
if (EdidDiscovered->SizeOfEdid != 0) {
Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_EDID_DISCOVERED_DATA), NULL);
@@ -575,6 +590,9 @@ EdidActiveProtocolDumpInformation ( RetVal = CatSPrint (NULL, Temp, EdidActive->SizeOfEdid);
SHELL_FREE_NON_NULL (Temp);
+ if (RetVal == NULL) {
+ return NULL;
+ }
if (EdidActive->SizeOfEdid != 0) {
Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_EDID_ACTIVE_DATA), NULL);
@@ -790,6 +808,9 @@ TxtOutProtocolDumpInformation ( Size = (Dev->Mode->MaxMode + 1) * 80;
RetVal = AllocateZeroPool (Size);
+ if (RetVal == NULL) {
+ return NULL;
+ }
Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_TXT_OUT_DUMP_HEADER), NULL);
if (Temp != NULL) {
@@ -801,6 +822,11 @@ TxtOutProtocolDumpInformation ( // Dump TextOut Info
//
Temp = HiiGetString (mHandleParsingHiiHandle, STRING_TOKEN (STR_TXT_OUT_DUMP_LINE), NULL);
+ if (Temp == NULL) {
+ FreePool (RetVal);
+ return NULL;
+ }
+
for (Index = 0; Index < Dev->Mode->MaxMode; Index++) {
Status = Dev->QueryMode (Dev, Index, &Col, &Row);
NewSize = Size - StrSize (RetVal);
@@ -1056,6 +1082,10 @@ BusSpecificDriverOverrideProtocolDumpInformation ( ConvertHandleToHandleIndex (ImageHandle),
ConvertDevicePathToText (LoadedImage->FilePath, TRUE, TRUE)
);
+ if (TempRetVal == NULL) {
+ break;
+ }
+
StrnCatGrow (&RetVal, &Size, TempRetVal, 0);
SHELL_FREE_NON_NULL (TempRetVal);
}
@@ -1287,6 +1317,11 @@ PciIoProtocolDumpInformation ( Pci.Hdr.ClassCode[1],
Pci.Hdr.ClassCode[2]
);
+ if (RetVal == NULL) {
+ FreePool (GetString);
+ return NULL;
+ }
+
for (Index = 0; Index < sizeof (Pci); Index++) {
if ((Index % 0x10) == 0) {
TempRetVal = CatSPrint (RetVal, L"\r\n %02x", *((UINT8 *)(&Pci) + Index));
@@ -1435,6 +1470,10 @@ AdapterInformationDumpInformation ( }
RetVal = CatSPrint (NULL, TempStr);
+ if (RetVal == NULL) {
+ goto ERROR_EXIT;
+ }
+
SHELL_FREE_NON_NULL (TempStr);
for (GuidIndex = 0; GuidIndex < InfoTypesBufferCount; GuidIndex++) {
@@ -1726,6 +1765,10 @@ FirmwareManagementDumpInformation ( }
RetVal = CatSPrint (NULL, TempStr, ImageInfoSize);
+ if (RetVal == NULL) {
+ goto ERROR_EXIT;
+ }
+
SHELL_FREE_NON_NULL (TempStr);
//
@@ -1823,37 +1866,65 @@ FirmwareManagementDumpInformation ( } else {
AttributeSettingStr = CatSPrint (NULL, L"(");
+ if (AttributeSettingStr == NULL) {
+ goto ERROR_EXIT;
+ }
+
if ((AttributeSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE) != 0x0) {
TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_IMAGE_UPDATABLE");
+ if (TempRetVal == NULL) {
+ goto ERROR_EXIT;
+ }
+
SHELL_FREE_NON_NULL (AttributeSettingStr);
AttributeSettingStr = TempRetVal;
}
if ((AttributeSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED) != 0x0) {
TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_RESET_REQUIRED");
+ if (TempRetVal == NULL) {
+ goto ERROR_EXIT;
+ }
+
SHELL_FREE_NON_NULL (AttributeSettingStr);
AttributeSettingStr = TempRetVal;
}
if ((AttributeSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED) != 0x0) {
TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED");
+ if (TempRetVal == NULL) {
+ goto ERROR_EXIT;
+ }
+
SHELL_FREE_NON_NULL (AttributeSettingStr);
AttributeSettingStr = TempRetVal;
}
if ((AttributeSetting & IMAGE_ATTRIBUTE_IN_USE) != 0x0) {
TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_IN_USE");
+ if (TempRetVal == NULL) {
+ goto ERROR_EXIT;
+ }
+
SHELL_FREE_NON_NULL (AttributeSettingStr);
AttributeSettingStr = TempRetVal;
}
if ((AttributeSetting & IMAGE_ATTRIBUTE_UEFI_IMAGE) != 0x0) {
TempRetVal = CatSPrint (AttributeSettingStr, L" IMAGE_ATTRIBUTE_UEFI_IMAGE");
+ if (TempRetVal == NULL) {
+ goto ERROR_EXIT;
+ }
+
SHELL_FREE_NON_NULL (AttributeSettingStr);
AttributeSettingStr = TempRetVal;
}
TempRetVal = CatSPrint (AttributeSettingStr, L" )");
+ if (TempRetVal == NULL) {
+ goto ERROR_EXIT;
+ }
+
SHELL_FREE_NON_NULL (AttributeSettingStr);
AttributeSettingStr = TempRetVal;
}
@@ -1958,7 +2029,7 @@ FirmwareManagementDumpInformation ( if (ImageInfoV1[Index].ImageId == ImageInfoV1[Index1].ImageId) {
Found = TRUE;
//
- // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
+ // At least one match found indicating presence of non unique ImageId values so no more comparisons needed
//
goto ENDLOOP;
}
@@ -1966,7 +2037,7 @@ FirmwareManagementDumpInformation ( if (ImageInfoV2[Index].ImageId == ImageInfoV2[Index1].ImageId) {
Found = TRUE;
//
- // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
+ // At least one match found indicating presence of non unique ImageId values so no more comparisons needed
//
goto ENDLOOP;
}
@@ -1974,7 +2045,7 @@ FirmwareManagementDumpInformation ( if (ImageInfo[Index].ImageId == ImageInfo[Index1].ImageId) {
Found = TRUE;
//
- // At least one match found indicating presense of non unique ImageId values so no more comparisons needed
+ // At least one match found indicating presence of non unique ImageId values so no more comparisons needed
//
goto ENDLOOP;
}
@@ -2187,7 +2258,6 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { { STRING_TOKEN (STR_SCSI_PT_EXT), &gEfiExtScsiPassThruProtocolGuid, NULL },
{ STRING_TOKEN (STR_ISCSI), &gEfiIScsiInitiatorNameProtocolGuid, NULL },
{ STRING_TOKEN (STR_USB_IO), &gEfiUsbIoProtocolGuid, UsbIoProtocolDumpInformation },
- { STRING_TOKEN (STR_USB_HC), &gEfiUsbHcProtocolGuid, NULL },
{ STRING_TOKEN (STR_USB_HC2), &gEfiUsb2HcProtocolGuid, NULL },
{ STRING_TOKEN (STR_DEBUG_SUPPORT), &gEfiDebugSupportProtocolGuid, DebugSupportProtocolDumpInformation },
{ STRING_TOKEN (STR_DEBUG_PORT), &gEfiDebugPortProtocolGuid, NULL },
@@ -2238,8 +2308,6 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { { STRING_TOKEN (STR_SHELL_ENV2), &gEfiShellEnvironment2Guid, NULL },
{ STRING_TOKEN (STR_SHELL_ENV), &gEfiShellEnvironment2Guid, NULL },
{ STRING_TOKEN (STR_DEVICE_IO), &gEfiDeviceIoProtocolGuid, NULL },
- { STRING_TOKEN (STR_UGA_DRAW), &gEfiUgaDrawProtocolGuid, NULL },
- { STRING_TOKEN (STR_UGA_IO), &gEfiUgaIoProtocolGuid, NULL },
{ STRING_TOKEN (STR_ESP), &gEfiPartTypeSystemPartGuid, NULL },
{ STRING_TOKEN (STR_GPT_NBR), &gEfiPartTypeLegacyMbrGuid, NULL },
{ STRING_TOKEN (STR_DRIVER_CONFIG), &gEfiDriverConfigurationProtocolGuid, NULL },
@@ -2848,7 +2916,11 @@ GetStringNameFromHandle ( );
if (!EFI_ERROR (Status)) {
BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);
- Status = CompNameStruct->GetDriverName (CompNameStruct, BestLang, &RetVal);
+ if (BestLang == NULL) {
+ return (NULL);
+ }
+
+ Status = CompNameStruct->GetDriverName (CompNameStruct, BestLang, &RetVal);
if (BestLang != NULL) {
FreePool (BestLang);
BestLang = NULL;
@@ -2869,7 +2941,11 @@ GetStringNameFromHandle ( );
if (!EFI_ERROR (Status)) {
BestLang = GetBestLanguageForDriver (CompNameStruct->SupportedLanguages, Language, FALSE);
- Status = CompNameStruct->GetDriverName (CompNameStruct, BestLang, &RetVal);
+ if (BestLang == NULL) {
+ return (NULL);
+ }
+
+ Status = CompNameStruct->GetDriverName (CompNameStruct, BestLang, &RetVal);
if (BestLang != NULL) {
FreePool (BestLang);
}
|