summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPali Rohár <[email protected]>2022-02-07 10:12:24 +0100
committerStefan Roese <[email protected]>2022-02-10 07:12:16 +0100
commit9e6d71d2b55f156c907d073825359d6ae441d9cf (patch)
treede5404b159169d5766ffbc8bc6741ba17aa8d01e
parentc153576d8dfc80c651a7edb046adbaa1c1c17e42 (diff)
tools: kwboot: Allow to use -b without image path as the last getopt() option
Currently it is possible to call "kwboot -b -t /dev/ttyUSB0" but not to call "kwboot -b /dev/ttyUSB0". Fix it by not trying to process the last argv[], which is non-getopt() option (tty path) as the image path for -b. Fixes: c513fe47dca2 ("tools: kwboot: Allow to use option -b without image path") Reported-by: Marcel Ziswiler <[email protected]> Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Marcel Ziswiler <[email protected]> Tested-by: Marcel Ziswiler <[email protected]>
-rw-r--r--tools/kwboot.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c
index 7737188f0d0..68c0ef1f1b0 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -1770,7 +1770,7 @@ main(int argc, char **argv)
bootmsg = kwboot_msg_boot;
if (prev_optind == optind)
goto usage;
- if (argv[optind] && argv[optind][0] != '-')
+ if (optind < argc - 1 && argv[optind] && argv[optind][0] != '-')
imgpath = argv[optind++];
break;