Skip to content

Commit

Permalink
UefiVariableSupport: bug fix missing variable definition(#584)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apop5 authored Jun 17, 2024
1 parent 3984542 commit 912993d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions edk2toollib/os/uefivariablesupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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])

Expand Down

0 comments on commit 912993d

Please sign in to comment.