[RFC PATCH 1/1] cmd: nvedit: Forbid key to be empty.
Wolfgang Denk
wd at denx.de
Tue Jun 29 10:29:06 CEST 2021
Dear Francis,
In message <20210628193145.796999-2-francis.laniel at amarulasolutions.com> you wrote:
> 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)) {
Instead of calling a library function here you could use the same
shortcut as in the patch you referenced:
if (*name == 0) {
> + printf("## Error: variable name cannot be empty\n");
s/cannot/must not/ ??
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The fundamental principle of science, the definition almost, is
this: the sole test of the validity of any idea is experiment."
- Richard P. Feynman
More information about the U-Boot
mailing list