Skip to contentSkip to conversation

dm: Prevent "demo hello" and "demo status" segfaults

PATCH New Peter Tyser 2 participants 4 messages Feb 3, 2015 – Feb 6, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 dm: Prevent "demo hello" and "demo status" segfaults

Segfaults can occur when a mandatory argument is not provided to "demo hello" and "demo status". Eg:

=> demo hello
Segmentation fault (core dumped)

Add a check to ensure all required arguments are provided.

---
 common/cmd_demo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
common/cmd_demo.c +3 -1
index 652c61c..b8b8578 100644
@@ -76,7 +76,9 @@ static int do_demo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				ARRAY_SIZE(demo_commands));
 	argc -= 2;
 	argv += 2;
-	if (!demo_cmd || argc > demo_cmd->maxargs)
+
+	if ((!demo_cmd || argc > demo_cmd->maxargs) ||
+	    ((demo_cmd->name[0] != 'l') && (argc < 1)))
 		return CMD_RET_USAGE;
 
 	if (argc) {
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 dm: Prevent "demo hello" and "demo status" segfaults

Hi Simon,

Quoted 9 lines · Peter Tyser

Segfaults can occur when a mandatory argument is not provided to "demo hello" and "demo status". Eg:

=> demo hello
Segmentation fault (core dumped)

Add a check to ensure all required arguments are provided.

The "1/3" in the subject line is an error - there are no other patches in the series.

Peter

#2 lore raw

PATCH 1/3 dm: Prevent "demo hello" and "demo status" segfaults

Quoted 9 lines · Peter Tyser

Hi Simon,

Quoted 6 lines · Peter Tyser

Segfaults can occur when a mandatory argument is not provided to "demo hello" and "demo status". Eg:

=> demo hello
Segmentation fault (core dumped)

Quoted 8 lines
Quoted 3 lines

Add a check to ensure all required arguments are provided.

The "1/3" in the subject line is an error - there are no other patches in the series.

Peter

Applied to u-boot-dm, thanks!

#3 lore raw

PATCH 1/3 dm: Prevent "demo hello" and "demo status" segfaults

In reply to Peter Tyser
Quoted 6 lines · Peter Tyser

Segfaults can occur when a mandatory argument is not provided to "demo hello" and "demo status". Eg:

=> demo hello
Segmentation fault (core dumped)

Quoted 6 lines

Add a check to ensure all required arguments are provided.

---
 common/cmd_demo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Thanks!