"Das U-Boot" Source Tree
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd: nvedit: Validate argument count before use

Avoid NULL pointer dereference in case 'env select' is invoked
without parameters, check the arg count and make sure it is at
least 2, otherwise print usage.

The crash is easy to trigger e.g. in sandbox:
$ ./u-boot -Tc "env select"

Fixes: a97d22ebba23 ("cmd: env: add env select command")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Tested-by: Vincent Stehlé <vincent.stehle@arm.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

authored by

Marek Vasut and committed by
Tom Rini
2333d446 d865f2f0

+3
+3
cmd/nvedit.c
··· 499 499 static int do_env_select(struct cmd_tbl *cmdtp, int flag, int argc, 500 500 char *const argv[]) 501 501 { 502 + if (argc < 2) 503 + return CMD_RET_USAGE; 504 + 502 505 return env_select(argv[1]) ? 1 : 0; 503 506 } 504 507 #endif