From: Andreas Reichel <[email protected]>

A user variable can be set to an empty string or it can be deleted. The
API distinguishes both cases using a USERVAR_TYPE_DELETED flag.

However, if a variable does not exist, and this flag is given, the
variable is wrongly created with the flag.

Fix the setter function so that if bgenv_find_uservar returns NULL, it
returns with no operation.

Signed-off-by: Andreas Reichel <[email protected]>
---
 env/uservars.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/env/uservars.c b/env/uservars.c
index 7e3dc26..c02bc14 100644
--- a/env/uservars.c
+++ b/env/uservars.c
@@ -140,8 +140,11 @@ int bgenv_set_uservar(uint8_t *udata, char *key, uint64_t 
type, void *data,
 
                p = bgenv_uservar_realloc(udata, total_size, p);
        } else {
-               p = bgenv_uservar_alloc(udata, total_size);
-       }
+               if ((type & USERVAR_TYPE_DELETED) == 0) {
+                       p = bgenv_uservar_alloc(udata, total_size);
+               } else {
+                       return 0;
+       }       }
        if (!p) {
                return -errno;
        }
-- 
2.14.2

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/20171103155556.32160-5-andreas.reichel.ext%40siemens.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to