From f121677f66e41e6edcda7da9cb69dcb522b532ba Mon Sep 17 00:00:00 2001 From: MikeBeaton Date: Mon, 6 Sep 2021 10:38:12 +0100 Subject: [PATCH] BootEntryProtocol: Fix NULL deref bug --- Library/OcBootManagementLib/BootEntryManagement.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Library/OcBootManagementLib/BootEntryManagement.c b/Library/OcBootManagementLib/BootEntryManagement.c index ee10802b..8d4e544a 100644 --- a/Library/OcBootManagementLib/BootEntryManagement.c +++ b/Library/OcBootManagementLib/BootEntryManagement.c @@ -1389,8 +1389,12 @@ AddBootEntryFromBootOption ( if (CompareMem ( (PartitionEntry == NULL) ? &gEfiPartTypeUnusedGuid : &PartitionEntry->UniquePartitionGUID, &EntryProtocolDevPath->Partuuid, - sizeof (EFI_GUID)) == 0) { + sizeof (EFI_GUID)) == 0 + ) { FileSystem = InternalFileSystemForHandle (BootContext, Handles[Index], TRUE, NULL); + if (FileSystem == NULL) { + continue; + } Status = AddEntriesFromBootEntryProtocol ( BootContext, @@ -1409,12 +1413,14 @@ AddBootEntryFromBootOption ( *EntryProtocolPartuuid = PartitionEntry->UniquePartitionGUID; } } + if (EntryProtocolId != NULL) { *EntryProtocolId = AllocateCopyPool (StrSize (EntryProtocolDevPath->EntryName.PathName), EntryProtocolDevPath->EntryName.PathName); // // If NULL allocated, just continue as if we had not matched. // } + break; } }