From 4e420d5d1a12212d1479646245dfa24bf92561a3 Mon Sep 17 00:00:00 2001 From: Oliver Smith-Denny Date: Wed, 16 Oct 2024 11:00:46 -0700 Subject: [PATCH] Test --- edk2toollib/os/uefivariablesupport.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/edk2toollib/os/uefivariablesupport.py b/edk2toollib/os/uefivariablesupport.py index 3f087dbd..13969f03 100644 --- a/edk2toollib/os/uefivariablesupport.py +++ b/edk2toollib/os/uefivariablesupport.py @@ -137,7 +137,15 @@ def GetUefiVar(self, name: str, guid: str) -> tuple[int, str]: efi_var = fd.read() length = len(efi_var) - return (err, efi_var[:length]) + # Unpack a uint32 from the start of efi_var, which is the attributes + # we always expect the attributes to be 7, since we are reading from runtime, + # report an error so the user knows it may fail to load if not 7 + attrs, = struct.unpack("=I", efi_var[:4]) + if attrs != 7: + logging.error(f"Unexpected attributes value: {attrs} for {name}-{guid}") + efi_var = efi_var[4:length] + + return (err, efi_var) def GetUefiAllVarNames(self) -> tuple[int, bytes]: """Get all Uefi Variables in the system, and return a byte packed byte string.