X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_update.c;h=9526ec2d954b9ce9eb14eca64aaa57bab2eb6941;hp=11a00bb5f036b81e5dbc5cccf2a76b7ecdf88e0c;hb=d92fa11949eb31c2ac038286fde8fab63bffd9c0;hpb=8a092a1ac0d22448114c29c2d872769340965132 diff --git a/src/rrd_update.c b/src/rrd_update.c index 11a00bb..9526ec2 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.3.2 Copyright by Tobi Oetiker, 1997-2008 + * RRDtool 1.4.2 Copyright by Tobi Oetiker, 1997-2009 * Copyright by Florian Forster, 2008 ***************************************************************************** * rrd_update.c RRD Update Function @@ -905,12 +905,16 @@ static int parse_ds( if (i < tmpl_cnt) { updvals[tmpl_idx[i++]] = p + 1; } + else { + rrd_set_error("found extra data on update argument: %s",p+1); + return -1; + } } } if (i != tmpl_cnt) { rrd_set_error("expected %lu data source readings (got %lu) from %s", - tmpl_cnt - 1, i, input); + tmpl_cnt - 1, i - 1, input); return -1; } @@ -972,6 +976,11 @@ static int get_time_from_reading( return -1; }; setlocale(LC_NUMERIC, old_locale); + if (tmp < 0.0){ + gettimeofday(&tmp_time, 0); + tmp = (double)tmp_time.tv_sec + (double)tmp_time.tv_usec * 1e-6f + tmp; + } + *current_time = floor(tmp); *current_time_usec = (long) ((tmp - (double) *current_time) * 1e6f); } @@ -1034,10 +1043,20 @@ static int update_pdp_prep( switch (dst_idx) { case DST_COUNTER: case DST_DERIVE: - for (ii = 0; updvals[ds_idx + 1][ii] != '\0'; ii++) { - if ((updvals[ds_idx + 1][ii] < '0' - || updvals[ds_idx + 1][ii] > '9') - && (ii != 0 && updvals[ds_idx + 1][ii] != '-')) { + if ( ( updvals[ds_idx + 1][0] < '0' + || updvals[ds_idx + 1][0] > '9' ) + && updvals[ds_idx + 1][0] != '-' + && updvals[ds_idx + 1][0] != 'U' + && updvals[ds_idx + 1][0] == '\0' + ) { + rrd_set_error("not a simple integer: '%s'", + updvals[ds_idx + 1]); + return -1; + } + for (ii = 1; updvals[ds_idx + 1][ii] != '\0'; ii++) { + if ( updvals[ds_idx + 1][ii] < '0' + || updvals[ds_idx + 1][ii] > '9' + ) { rrd_set_error("not a simple integer: '%s'", updvals[ds_idx + 1]); return -1;