[PATCH 5/5] bugfix: uservars: Fix deletion of deleted variables.

3 views
Skip to first unread message

Andreas J. Reichel

unread,
Nov 3, 2017, 7:53:50 AM11/3/17
to efibootg...@googlegroups.com, Andreas Reichel
From: Andreas Reichel <andreas.r...@siemens.com>

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 <andreas.r...@siemens.com>
---
env/uservars.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/env/uservars.c b/env/uservars.c
index f6013c1..791cce7 100644
--- a/env/uservars.c
+++ b/env/uservars.c
@@ -133,8 +133,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

Reply all
Reply to author
Forward
0 new messages