From: Marek Schimara Date: Wed, 15 Jun 2016 07:59:25 +0000 (+0200) Subject: src/rrd_tune.c: fix Coverity CID#32424 Improper use of negative value X-Git-Tag: v1.7.0~42^2~58 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=2dbf5f70cedcafec2350e2178a2b9ae85997743b;p=thirdparty%2Frrdtool-1.x.git src/rrd_tune.c: fix Coverity CID#32424 Improper use of negative value 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. --- diff --git a/src/rrd_tune.c b/src/rrd_tune.c index 47163c28..03a16590 100644 --- a/src/rrd_tune.c +++ b/src/rrd_tune.c @@ -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()) {