]> git.sur5r.net Git - openocd/commitdiff
flash/nor/tcl: fix segfault on write_image misuse
authorPaul Fertser <fercerpav@gmail.com>
Tue, 25 Feb 2014 17:22:11 +0000 (21:22 +0400)
committerPaul Fertser <fercerpav@gmail.com>
Sat, 29 Mar 2014 06:55:13 +0000 (06:55 +0000)
"flash write_image (unlock|erase)" (without filename) was causing
segmentation fault in strcmp(). This patch fixes it.

Change-Id: Ia3b8c796f4107621d78605c02d2b8e123b1b207b
Reported-by: ajkroll][ <ajkroll][@irc.freenode.net>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1970
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/flash/nor/tcl.c

index 916ebf73848153af10e621bb78ab68c6723cf551..32a666cc87bd2508aaf40e80137d6993857ed52a 100644 (file)
@@ -349,14 +349,11 @@ COMMAND_HANDLER(handle_flash_write_image_command)
 
        int retval;
 
-       if (CMD_ARGC < 1)
-               return ERROR_COMMAND_SYNTAX_ERROR;
-
        /* flash auto-erase is disabled by default*/
        int auto_erase = 0;
        bool auto_unlock = false;
 
-       for (;; ) {
+       while (CMD_ARGC) {
                if (strcmp(CMD_ARGV[0], "erase") == 0) {
                        auto_erase = 1;
                        CMD_ARGV++;