]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
src/rrd_tune.c: fix Coverity CID#32424 Improper use of negative value
authorMarek Schimara <Marek.Schimara@bull.net>
Wed, 15 Jun 2016 07:59:25 +0000 (09:59 +0200)
committerMarek Schimara <Marek.Schimara@bull.net>
Thu, 23 Jun 2016 14:32:32 +0000 (16:32 +0200)
        CWE-394 / https://cwe.mitre.org/data/definitions/394.html

        Note: optparse_init() and optparse_long() which can modify the
        'options' variable in rrd_tune() can never set options.optind
        to a negative value.

src/rrd_tune.c

index 47163c286915b557256d57e439a1a19bc0a13ca4..03a16590a555c8e4fc5f26000b98e1cede87eff8 100644 (file)
@@ -153,7 +153,7 @@ int rrd_tune(
        opt_daemon = NULL;
     }
 
-    if (options.optind < 0 || options.optind >= options.argc) {
+    if (!options.optind || options.optind >= options.argc) {
        // missing file name...
        rrd_set_error("missing file name");
        goto done;
@@ -405,10 +405,6 @@ int rrd_tune(
     }
 
     optind = handle_modify(&rrd, in_filename, options.argc, options.argv, options.optind + 1, opt_newstep);
-    if (options.optind < 0) {
-       goto done;
-    }
-    
     rc = 0;
 done:
     if (in_filename && rrdc_is_any_connected()) {