diff options
author | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2022-12-18 09:08:57 +0300 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2022-12-20 18:06:48 +0300 |
commit | 70a4ac693d3f1e5ce8cc1bc919c9bd080e1bda77 (patch) | |
tree | c1fdb3b4166763fe39e774d9d29ffee798c437ad /lib | |
parent | 645502743ac10ffaa5abf944bf0b751b32b47220 (diff) | |
download | u-boot-70a4ac693d3f1e5ce8cc1bc919c9bd080e1bda77.tar.xz |
efi_loader: fix efi_get_next_variable_name_mem()
The VariableNameSize parameter is in bytes but u16_strnlen() counts u16.
Fix the parameter check for null termination.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/efi_loader/efi_var_mem.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/efi_loader/efi_var_mem.c b/lib/efi_loader/efi_var_mem.c index 13909b1d26..0bac594e00 100644 --- a/lib/efi_loader/efi_var_mem.c +++ b/lib/efi_loader/efi_var_mem.c @@ -315,14 +315,14 @@ efi_get_next_variable_name_mem(efi_uintn_t *variable_name_size, u16 *variable_name, efi_guid_t *vendor) { struct efi_var_entry *var; - efi_uintn_t old_size; + efi_uintn_t len, old_size; u16 *pdata; if (!variable_name_size || !variable_name || !vendor) return EFI_INVALID_PARAMETER; - if (u16_strnlen(variable_name, *variable_name_size) == - *variable_name_size) + len = *variable_name_size >> 1; + if (u16_strnlen(variable_name, len) == len) return EFI_INVALID_PARAMETER; if (!efi_var_mem_find(vendor, variable_name, &var) && *variable_name) |