From 28e068b2e0195a6356c43f90df52de6c5edca1c1 Mon Sep 17 00:00:00 2001 From: Nate DeSimone Date: Mon, 10 Mar 2025 18:22:51 -0700 Subject: [PATCH] Fix to_dict() to handle FVs without a FV Name If an FV does not contain the optional EFI_FIRMWARE_VOLUME_EXT_HEADER, then the to_dict() function will crash. The crash occurs when attempting to access the fvname attribute, because the fvname attribute does not exist in this case. The fix is to check if the fvname attribute does not exist. If it does not, set nameGuid to None. Signed-off-by: Nate DeSimone --- uefi_firmware/uefi.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/uefi_firmware/uefi.py b/uefi_firmware/uefi.py index 2605cd0..6634d3a 100644 --- a/uefi_firmware/uefi.py +++ b/uefi_firmware/uefi.py @@ -1516,9 +1516,13 @@ def to_dict(self): # TODO? for raw in self.raw_objects: + fvname = None + if hasattr(self, 'fvname'): + fvname = sguid(self.fvname) + return { 'guid': sguid(self.guid), - 'nameGuid': sguid(self.fvname), + 'nameGuid': fvname, 'attributes': self.attributes, 'revision': self.revision, 'checksum': self.checksum,