From 36b2cea412a96a72097c6ef634c9e406834b162b Mon Sep 17 00:00:00 2001 From: Mike Beaton Date: Sat, 14 Oct 2023 20:02:26 +0100 Subject: [PATCH] OcBootManagementLib: Fix incorrect handling of optional DataLength parameter Introduced by 546aa5ba6415902ed05db02f8a5448c5e7ff67cf --- Changelog.md | 1 + Include/Acidanthera/Library/OcBootManagementLib.h | 4 ++-- Library/OcBootManagementLib/BootEntryInfo.c | 15 ++++++++++----- Library/OcBootManagementLib/BootEntryManagement.c | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index 1d76d1e1cb2..de3b144acc9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ OpenCore Changelog ================== #### v0.9.6 - Updated builtin firmware versions for SMBIOS and the rest +- Fixed hang while generating boot entries on some systems #### v0.9.5 - Fixed GUID formatting for legacy NVRAM saving diff --git a/Include/Acidanthera/Library/OcBootManagementLib.h b/Include/Acidanthera/Library/OcBootManagementLib.h index 8632ad67b0f..b443863a85b 100644 --- a/Include/Acidanthera/Library/OcBootManagementLib.h +++ b/Include/Acidanthera/Library/OcBootManagementLib.h @@ -2186,7 +2186,7 @@ OcGetBootEntryFileFromDevicePath ( IN UINT32 MaxFileSize, IN UINT32 MinFileSize, OUT VOID **FileData, - OUT UINT32 *DataLength, + OUT UINT32 *DataLength OPTIONAL, IN BOOLEAN SearchAtLeaf, IN BOOLEAN SearchAtRoot ); @@ -2218,7 +2218,7 @@ OcGetBootEntryFile ( IN UINT32 MaxFileSize, IN UINT32 MinFileSize, OUT VOID **FileData, - OUT UINT32 *DataLength, + OUT UINT32 *DataLength OPTIONAL, IN BOOLEAN SearchAtLeaf, IN BOOLEAN SearchAtRoot ); diff --git a/Library/OcBootManagementLib/BootEntryInfo.c b/Library/OcBootManagementLib/BootEntryInfo.c index b150ea334bb..e34e667a04c 100644 --- a/Library/OcBootManagementLib/BootEntryInfo.c +++ b/Library/OcBootManagementLib/BootEntryInfo.c @@ -401,6 +401,7 @@ OcGetBootEntryLabelImage ( OUT UINT32 *DataLength ) { + ASSERT (DataLength != NULL); return OcGetBootEntryFile ( BootEntry, Scale == 2 ? L".disk_label_2x" : L".disk_label", @@ -423,6 +424,7 @@ OcGetBootEntryIcon ( OUT UINT32 *DataLength ) { + ASSERT (DataLength != NULL); return OcGetBootEntryFile ( BootEntry, L".VolumeIcon.icns", @@ -446,7 +448,7 @@ InternalGetBootEntryFile ( IN UINT32 MaxFileSize, IN UINT32 MinFileSize, OUT VOID **FileData, - OUT UINT32 *DataLength, + OUT UINT32 *DataLength OPTIONAL, IN BOOLEAN SearchAtLeaf, IN BOOLEAN SearchAtRoot ) @@ -458,9 +460,12 @@ InternalGetBootEntryFile ( ASSERT (SearchAtLeaf || SearchAtRoot); ASSERT (DevicePath != NULL); + ASSERT (FileData != NULL); - *FileData = NULL; - *DataLength = 0; + *FileData = NULL; + if (DataLength != NULL) { + *DataLength = 0; + } Status = OcBootPolicyDevicePathToDirPath ( DevicePath, @@ -564,7 +569,7 @@ OcGetBootEntryFileFromDevicePath ( IN UINT32 MaxFileSize, IN UINT32 MinFileSize, OUT VOID **FileData, - OUT UINT32 *DataLength, + OUT UINT32 *DataLength OPTIONAL, IN BOOLEAN SearchAtLeaf, IN BOOLEAN SearchAtRoot ) @@ -592,7 +597,7 @@ OcGetBootEntryFile ( IN UINT32 MaxFileSize, IN UINT32 MinFileSize, OUT VOID **FileData, - OUT UINT32 *DataLength, + OUT UINT32 *DataLength OPTIONAL, IN BOOLEAN SearchAtLeaf, IN BOOLEAN SearchAtRoot ) diff --git a/Library/OcBootManagementLib/BootEntryManagement.c b/Library/OcBootManagementLib/BootEntryManagement.c index f0a903ce1c9..6f6d62ee20f 100644 --- a/Library/OcBootManagementLib/BootEntryManagement.c +++ b/Library/OcBootManagementLib/BootEntryManagement.c @@ -192,6 +192,7 @@ ExpandShortFormBootPath ( /** Check boot entry visibility by device path. + @param[in] Context Picker context. @param[in] DevicePath Device path of the entry. @return Entry visibility