[RFC PATCH 1/1] cmd: nvedit: Forbid key to be empty.

Francis Laniel francis.laniel at amarulasolutions.com
Mon Jun 28 21:31:45 CEST 2021


Before this patch, it was possible to do the following using setenv:
setenv '' foo
Then, on next reboot, U-Boot will not be able to parse environment due to it
having:
=foo

Now, if the above command is given, an error message is thrown and environment
is not modified.

Signed-off-by: Francis Laniel <francis.laniel at amarulasolutions.com>
---
 cmd/nvedit.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index d14ba10cef..64b7aef78d 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -262,6 +262,11 @@ static int _do_env_set(int flag, int argc, char *const argv[], int env_flag)
 		return 1;
 	}
 
+	if (!strlen(name)) {
+		printf("## Error: variable name cannot be empty\n");
+		return 1;
+	}
+
 	env_id++;
 
 	/* Delete only ? */
-- 
2.25.1



More information about the U-Boot mailing list