X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Frrd_update.c;h=9526ec2d954b9ce9eb14eca64aaa57bab2eb6941;hb=a677dd48db923ddfb32e59291f05fbb185eb8ca0;hp=5c607027fde0617cf608794f9252dc5005a7b0df;hpb=ac80502874611b14e8d7361ab8af22e252c0385b;p=rrdtool.git diff --git a/src/rrd_update.c b/src/rrd_update.c index 5c60702..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; @@ -1896,7 +1915,7 @@ static int write_to_rras( scratch_idx = CDP_secondary_val, step_subtract = 2) { - off_t rra_pos_new; + size_t rra_pos_new; #ifdef DEBUG fprintf(stderr, " -- RRA Preseek %ld\n", rrd_file->pos); #endif