mirror of
https://git.proxmox.com/git/efi-boot-shim
synced 2025-10-04 22:59:39 +00:00
get_variable: always allocate a NUL character at the end.
Sometimes we're loading structures that are parsed in string-like ways, but can't necessarily be trusted to be zero-terminated. Solve that by making sure we always have enough aligned, trailing zero bytes to always have at least one NUL character, no matter which character type is being parsed. Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
parent
94ad063e94
commit
b0a2ea0caa
@ -245,7 +245,11 @@ get_variable_attr(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner,
|
|||||||
return efi_status;
|
return efi_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
*data = AllocateZeroPool(*len);
|
/*
|
||||||
|
* Add three zero pad bytes; at least one correctly aligned UCS-2
|
||||||
|
* character.
|
||||||
|
*/
|
||||||
|
*data = AllocateZeroPool(*len + 3);
|
||||||
if (!*data)
|
if (!*data)
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
|
||||||
@ -254,6 +258,7 @@ get_variable_attr(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner,
|
|||||||
FreePool(*data);
|
FreePool(*data);
|
||||||
*data = NULL;
|
*data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return efi_status;
|
return efi_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user