Skip to contentSkip to conversation

pxe: Fix crash if 'sysboot' is run without args

PATCH New Tuomas Tynkkynen 3 participants 6 messages May 7, 2015 – May 28, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 pxe: Fix crash if 'sysboot' is run without args

Previously, a NULL pointer dereference would occur if the 'sysboot' command is executed without any arguments.

---
 common/cmd_pxe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd_pxe.c +1 -1
index 4cbb2b1..abf0941 100644
@@ -1648,7 +1648,7 @@ static int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	is_pxe = false;
 
-	if (strstr(argv[1], "-p")) {
+	if (argc > 1 && strstr(argv[1], "-p")) {
 		prompt = 1;
 		argc--;
 		argv++;
Signature · 1 line
2.4.0
#1 lore raw

PATCH 2/2 menu: Return an error code if Ctrl-C is pressed

Previously, if the menu activated by the 'sysboot' command gets interrupted by a Ctrl-C, the behaviour is as if the menu timeout was reached - i.e. boot the default menu entry. This patch fixes that so a Ctrl-C now terminates the command as the user would expect.

---
 common/menu.c | 3 +++
 1 file changed, 3 insertions(+)
menu.c +3 -0
index e81c074..eda96d6 100644
@@ -202,6 +202,9 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)
 				choice_item = menu_item_by_key(m, cbuf);
 				if (!choice_item)
 					printf("%s not found\n", cbuf);
+			} else if (readret == -1)  {
+				printf("<INTERRUPT>\n");
+				return -EINTR;
 			} else {
 				return menu_default_choice(m, choice);
 			}
Signature · 1 line
2.4.0
#2 lore raw

PATCH 2/2 menu: Return an error code if Ctrl-C is pressed

Hi Tuomas,

Quoted 25 lines · Tuomas Tynkkynen

Previously, if the menu activated by the 'sysboot' command gets interrupted by a Ctrl-C, the behaviour is as if the menu timeout was reached - i.e. boot the default menu entry. This patch fixes that so a Ctrl-C now terminates the command as the user would expect.

---
 common/menu.c | 3 +++
 1 file changed, 3 insertions(+)
menu.c +3 -1
index e81c074..eda96d6 100644
@@ -202,6 +202,9 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)
                                choice_item = menu_item_by_key(m, cbuf);
                                if (!choice_item)
                                        printf("%s not found\n", cbuf);
+                       } else if (readret == -1)  {
+                               printf("<INTERRUPT>\n");
+                               return -EINTR;
                        } else {
                                return menu_default_choice(m, choice);
                        }
--
Quoted 2 lines

2.4.0

If you feel like doing another patch, you could update the cli_readline_into_buffer() and cread_line() to describe the meaning of the return values (-1 and -2). Even better if you can use -EINTR and -ETIMEDOUT.

Regards,
Simon

#3 lore raw

PATCH 2/2 menu: Return an error code if Ctrl-C is pressed

In reply to Tuomas Tynkkynen
Quoted 7 lines · Tuomas Tynkkynen

Previously, if the menu activated by the 'sysboot' command gets interrupted by a Ctrl-C, the behaviour is as if the menu timeout was reached - i.e. boot the default menu entry. This patch fixes that so a Ctrl-C now terminates the command as the user would expect.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150528/0beaf132/attachment.sig>
#5 lore raw

PATCH 1/2 pxe: Fix crash if 'sysboot' is run without args

In reply to Tuomas Tynkkynen
Quoted 5 lines · Tuomas Tynkkynen

Previously, a NULL pointer dereference would occur if the 'sysboot' command is executed without any arguments.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150528/a08a26b5/attachment.sig>