efi_loader: fix GetNextVariableName
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Tue, 22 Jan 2019 19:10:46 +0000 (20:10 +0100)
committerAlexander Graf <agraf@suse.de>
Wed, 13 Feb 2019 08:40:06 +0000 (09:40 +0100)
Our current implementation of GetNextVariableName() first collects all EFI
variables. If none is found at all hexport_r() returns a zero length string
terminated by \0 and the value 1 as number of bytes in the returned buffer.

In this case GetNextVariableName() has to return EFI_NOT_FOUND.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
lib/efi_loader/efi_variable.c

index d94a5f69748dca4cb51a1f5a9d7ad90c52bef71f..e0d7f5736db20cfe3d1d94c4c069d93f2edd6d98 100644 (file)
@@ -383,7 +383,8 @@ efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size,
                list_len = hexport_r(&env_htab, '\n',
                                     H_MATCH_REGEX | H_MATCH_KEY,
                                     &efi_variables_list, 0, 1, regexlist);
-               if (list_len <= 0)
+               /* 1 indicates that no match was found */
+               if (list_len <= 1)
                        return EFI_EXIT(EFI_NOT_FOUND);
 
                variable = efi_variables_list;