cmd: nvedit: Forbid key to be empty.
A message that is not in the archive (sent off-list or not yet received): [email protected]
RFC PATCH 1/1 cmd: nvedit: Forbid key to be empty.
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.
--- cmd/nvedit.c | 5 +++++ 1 file changed, 5 insertions(+)
cmd/nvedit.c +5 -0
@@ -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 ? */
Signature · 1 line
2.25.1
Dear Francis,
Quoted 19 lines · In message <[email protected]> you…
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:
=fooNow, if the above command is given, an error message is thrown and environment is not modified.
Signed-off-by Francis Laniel <[email protected]>--- cmd/nvedit.c | 5 +++++ 1 file changed, 5 insertions(+)cmd/nvedit.c +0
-0
cmd/nvedit.c static int _do_env_set(int flag, int argc, char *const argv[], int env_flag) · line 265
Quoted 4 lines
cmd/nvedit.c +1
-0@@ -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) {cmd/nvedit.c static int _do_env_set(int flag, int argc, char *const argv[], int env_flag) · line 266
Quoted 1 line
cmd/nvedit.c +1
-0+printf ("## Error: variable name cannot be empty\n" );
s/cannot/must not/ ??
Best regards,
Wolfgang Denk
Signature · 6 lines
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: [email protected] "The fundamental principle of science, the definition almost, is this: the sole test of the validity of any idea is experiment." - Richard P. Feynman
Hi.
Quoted 44 lines · Wolfgang Denk
Dear Francis,
In message <[email protected]>
Quoted 3 lines · you
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 dueto it
Quoted 4 lines
having:
=fooNow, if the above command is given, an error message is thrown and
environment
cmd/nvedit.c static int _do_env_set(int flag, int argc, char
Quoted 12 lines
is not modified.
Signed-off-by Francis Laniel <[email protected]>--- cmd/nvedit.c | 5 +++++ 1 file changed, 5 insertions(+)cmd/nvedit.c +0
-0@@ -262,6 +262,11 @@ static int _do_env_set(int flag, int argc, char*const argv[], int
env_flag)cmd/nvedit.c static int _do_env_set(int flag, int argc, char *const argv[], int env_flag) · line 265
Quoted 4 lines
cmd/nvedit.c +1
-0return 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) {cmd/nvedit.c static int _do_env_set(int flag, int argc, char *const argv[], int env_flag) · line 266
Quoted 1 line
cmd/nvedit.c +1
-0+printf ("## Error: variable name cannot be empty\n" );s/cannot/must not/ ??
Best regards,
Wolfgang Denk
Quoted 8 lines
--
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: [email protected] "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.