From f2b8f788b4c5bf5be284df4aa2a3b787d20c16a1 Mon Sep 17 00:00:00 2001 From: Nate DeSimone Date: Mon, 25 Aug 2025 16:57:22 -0700 Subject: [PATCH] MultiObject.to_dict() should return all FVs Right now, MultiObject.to_dict() only returns FVs contained in the root MultiObject. It does not check if the MultiObject contains nested MultiObject instances that then contain Firmware Volumes. The fix is to make to_dict() perform a depth-first search through the tree of MultiObject instances and collect all FirmwareVolume objects in the tree. Signed-off-by: Nate DeSimone --- uefi_firmware/__init__.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/uefi_firmware/__init__.py b/uefi_firmware/__init__.py index ad8e10f..6962748 100644 --- a/uefi_firmware/__init__.py +++ b/uefi_firmware/__init__.py @@ -127,11 +127,17 @@ def showinfo(self, ts='', index=None): self.objs[i].showinfo(ts, i) def to_dict(self): - volumes = [] - for i in range(len(self.objs)): - obj = self.objs[i] - if type(obj) is uefi.FirmwareVolume: - volumes.append(obj.to_dict()) + def get_fvs(multi_object): + volumes = [] + for i in range(len(multi_object.objs)): + obj = multi_object.objs[i] + if type(obj) is uefi.FirmwareVolume: + volumes.append(obj.to_dict()) + if type(obj) is MultiObject: + volumes.extend(get_fvs(obj)) + return volumes + volumes = get_fvs(self) + return { 'regions': [ { 'type': 'bios',