From 912993d4b8d30989e51cb6c67e230d3b1ac23862 Mon Sep 17 00:00:00 2001 From: Aaron <105021049+apop5@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:09:47 -0700 Subject: [PATCH] UefiVariableSupport: bug fix missing variable definition(#584) GetUefiVariable originally returned a buffer which was larger than the variable size. This was modified to only return the buffer of the variable size, but the modification caused an exception (variable not initialized). Modifying the code again to initialize the variable, and to retrieve the correct variable size. --- edk2toollib/os/uefivariablesupport.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/edk2toollib/os/uefivariablesupport.py b/edk2toollib/os/uefivariablesupport.py index df8421b2..de14bedc 100644 --- a/edk2toollib/os/uefivariablesupport.py +++ b/edk2toollib/os/uefivariablesupport.py @@ -122,6 +122,7 @@ def GetUefiVar(self, name: str, guid: str) -> tuple[int, str]: Tuple: (error code, string of variable data) """ err = 0 + length = 0 # Remove null termination on the name, if it exists. name = name.rstrip('\x00') @@ -158,6 +159,7 @@ def GetUefiVar(self, name: str, guid: str) -> tuple[int, str]: efi_var = create_string_buffer(EFI_VAR_MAX_BUFFER_SIZE) with open(path, 'rb') as fd: efi_var = fd.read() + length = len(efi_var) return (err, efi_var[:length])