Crash in LoadLatestNvramPlist when EfiLibOpenRoot returns null.

This commit is contained in:
jief666 2021-05-19 15:28:57 +03:00
parent bf74520cef
commit 2b84ee61a3
3 changed files with 16 additions and 5 deletions

View File

@ -964,9 +964,17 @@ LoadLatestNvramPlist()
if (!EFI_ERROR(Status) && HandleCount > 0) {
for (UINTN indexHandle = 0; indexHandle < HandleCount; indexHandle++) {
RootDir = EfiLibOpenRoot(Handles[indexHandle]);
if ( RootDir == NULL ) {
DBG(" - [%lld] cannot open - skipping!\n", indexHandle);
continue;
}
Status = RootDir->Open(RootDir, &FileHandle, L"nvram.plist", EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) {
DBG(" - [%lld] no nvram.plist - skipping!\n", indexHandle);
if ( Status == EFI_NOT_FOUND ) {
DBG(" - [%lld] no nvram.plist\n", indexHandle);
}else{
DBG(" - [%lld] Cannot open nvram.plist - %s\n", indexHandle, efiStrError(Status));
}
continue;
}
FileInfo = EfiLibFileInfo(FileHandle);
@ -1077,7 +1085,7 @@ LoadLatestNvramPlist()
// DBG(" nvram.plist not found!\n");
// }
#endif
DBG("loaded Status=%s\n", efiStrError(Status));
DBG("LoadLatestNvramPlist loaded Status=%s\n", efiStrError(Status));
return Status;
}
@ -1096,7 +1104,7 @@ PutNvramPlistToRtVars ()
if (gNvramDict == NULL) {
/*Status = */LoadLatestNvramPlist();
if (gNvramDict == NULL) {
DBG("PutNvramPlistToRtVars: nvram.plist not found\n");
DBG("PutNvramPlistToRtVars: no nvram.plist\n");
return;
}
}

View File

@ -83,6 +83,9 @@ EFI_STATUS Self::_initialize()
}
m_efiFileName = m_CloverDirFullPath.basename();
#ifdef JIEF_DEBUG
DBG("m_efiFileName=%ls\n", m_efiFileName.wc_str());
#endif
// History : if this Clover was started as BootX64.efi, redirect to /EFI/CLOVER
if ( m_CloverDirFullPath.isEqualIC("\\EFI\\Boot\\BootX64.efi") ) {

View File

@ -193,9 +193,9 @@ static EFI_STATUS LoadEFIImageList(IN EFI_DEVICE_PATH **DevicePaths,
#ifdef JIEF_DEBUG
EFI_LOADED_IMAGE_PROTOCOL* loadedBootImage = NULL;
if (!EFI_ERROR(Status = gBS->HandleProtocol(ChildImageHandle, &gEfiLoadedImageProtocolGuid, (void**)(&loadedBootImage)))) {
DBG("%ls : Image base = 0x%llx", ImageTitle.wc_str(), (uintptr_t)loadedBootImage->ImageBase); // Jief : Do not change this, it's used by grep to feed the debugger
DBG("%ls : Image base = 0x%llx\n", ImageTitle.wc_str(), (uintptr_t)loadedBootImage->ImageBase); // Jief : Do not change this, it's used by grep to feed the debugger
}else{
DBG("Can't get loaded image protocol");
DBG("Can't get loaded image protocol\n");
}
#endif
goto bailout;