* [RFC PATCH 1/1] cmd: nvedit: Forbid key to be empty.
[not found] <20210628193145.796999-1-francis.laniel@amarulasolutions.com>
@ 2021-06-28 19:31 ` Francis Laniel
2021-06-29 8:29 ` Wolfgang Denk
0 siblings, 1 reply; 4+ messages in thread
From: Francis Laniel @ 2021-06-28 19:31 UTC (permalink / raw)
To: u-boot, joe.hershberger, wd; +Cc: michael, ondrej, Francis Laniel
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@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RFC PATCH 1/1] cmd: nvedit: Forbid key to be empty.
2021-06-28 19:39 [RFC PATCH 0/1] cmd: nvedit: Forbid environment " Francis Laniel
@ 2021-06-28 19:39 ` Francis Laniel
0 siblings, 0 replies; 4+ messages in thread
From: Francis Laniel @ 2021-06-28 19:39 UTC (permalink / raw)
To: u-boot, joe.hershberger, wd; +Cc: michael, ondrej, Francis Laniel
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@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH 1/1] cmd: nvedit: Forbid key to be empty.
2021-06-28 19:31 ` [RFC PATCH 1/1] cmd: nvedit: Forbid key to be empty Francis Laniel
@ 2021-06-29 8:29 ` Wolfgang Denk
2021-06-29 16:16 ` Francis Laniel
0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Denk @ 2021-06-29 8:29 UTC (permalink / raw)
To: Francis Laniel; +Cc: u-boot, joe.hershberger, michael, ondrej
Dear Francis,
In message <20210628193145.796999-2-francis.laniel@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@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@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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH 1/1] cmd: nvedit: Forbid key to be empty.
2021-06-29 8:29 ` Wolfgang Denk
@ 2021-06-29 16:16 ` Francis Laniel
0 siblings, 0 replies; 4+ messages in thread
From: Francis Laniel @ 2021-06-29 16:16 UTC (permalink / raw)
To: Wolfgang Denk
Cc: u-boot, joe.hershberger, Michael Nazzareno Trimarchi, Ondrej Pik
Hi.
On Tue, Jun 29, 2021 at 10:29 AM Wolfgang Denk <wd@denx.de> wrote:
> Dear Francis,
>
> In message <20210628193145.796999-2-francis.laniel@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@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@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
>
Thank you for the review, I updated my patch and will push soon the v2.
Best regards.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-29 16:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210628193145.796999-1-francis.laniel@amarulasolutions.com>
2021-06-28 19:31 ` [RFC PATCH 1/1] cmd: nvedit: Forbid key to be empty Francis Laniel
2021-06-29 8:29 ` Wolfgang Denk
2021-06-29 16:16 ` Francis Laniel
2021-06-28 19:39 [RFC PATCH 0/1] cmd: nvedit: Forbid environment " Francis Laniel
2021-06-28 19:39 ` [RFC PATCH 1/1] cmd: nvedit: Forbid " Francis Laniel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox