]> git.sur5r.net Git - openocd/commitdiff
svf: improve robustness when processing invalid SVF files
authorPaul Fertser <fercerpav@gmail.com>
Thu, 18 Jan 2018 08:59:10 +0000 (11:59 +0300)
committerPaul Fertser <fercerpav@gmail.com>
Tue, 13 Mar 2018 08:41:21 +0000 (08:41 +0000)
Uninitialized argument value warnings reported by clang static
analizer.

Change-Id: I30af4900f517ffc0a7282689b58c7a224cdc080a
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4356
Tested-by: jenkins
src/svf/svf.c

index 1d686ba6174c1e1e279ba66d36ac71b660f9faff..223af7e182bbe3693fa18c857b780fcb7326ea57 100644 (file)
@@ -741,6 +741,9 @@ parse_char:
                pos++;
        }
 
+       if (num == 0)
+               return ERROR_FAIL;
+
        *num_of_argu = num;
 
        return ERROR_OK;
@@ -1313,7 +1316,7 @@ XXR_common:
                         * SEC]] [ENDSTATE end_state] */
                        /* RUNTEST [run_state] min_time SEC [MAXIMUM max_time SEC] [ENDSTATE
                         * end_state] */
-                       if ((num_of_argu < 3) && (num_of_argu > 11)) {
+                       if ((num_of_argu < 3) || (num_of_argu > 11)) {
                                LOG_ERROR("invalid parameter of %s", argus[0]);
                                return ERROR_FAIL;
                        }