diff options
| author | Peter Jones <pjones@redhat.com> | 2021-02-13 13:02:14 -0500 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2021-02-13 13:15:12 -0500 |
| commit | b0a2ea0caa2ac501ceb96c46df4fc0d4eb6ec891 (patch) | |
| tree | f96938384523824adce47c422479198e5e8c6b3b /lib/variables.c | |
| parent | 94ad063e94a4378917f57720d618ce17d08e587d (diff) | |
| download | efi-boot-shim-b0a2ea0caa2ac501ceb96c46df4fc0d4eb6ec891.tar.gz efi-boot-shim-b0a2ea0caa2ac501ceb96c46df4fc0d4eb6ec891.zip | |
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>
Diffstat (limited to 'lib/variables.c')
| -rw-r--r-- | lib/variables.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/variables.c b/lib/variables.c index 8123ae60..5d909184 100644 --- a/lib/variables.c +++ b/lib/variables.c @@ -245,7 +245,11 @@ get_variable_attr(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner, 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) return EFI_OUT_OF_RESOURCES; @@ -254,6 +258,7 @@ get_variable_attr(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner, FreePool(*data); *data = NULL; } + return efi_status; } |
