efi_loader: appending to non-existent variable
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 26 Sep 2019 19:40:18 +0000 (21:40 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 6 Oct 2019 14:02:36 +0000 (16:02 +0200)
Appending to a non-existent variable must result in an error of type
EFI_NOT_FOUND.

Fixes: 09c76b79a9db ("efi_loader: SetVariable() deleting variables")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/efi_variable.c

index 4c554c546b21ca80dd6c6e8cf14f03f2f552905f..d0daf7bdebbf25536350a6bbf46aa160a5800567 100644 (file)
@@ -478,10 +478,12 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
                        old_size = 0;
                }
        } else {
-               if ((data_size == 0 &&
-                    !(attributes & EFI_VARIABLE_APPEND_WRITE)) ||
-                   !attributes) {
-                       /* delete, but nothing to do */
+               if (data_size == 0 || !attributes ||
+                   (attributes & EFI_VARIABLE_APPEND_WRITE)) {
+                       /*
+                        * Trying to delete or to update a non-existent
+                        * variable.
+                        */
                        ret = EFI_NOT_FOUND;
                        goto out;
                }