X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_restore.c;h=29a97b3bf67260a946bd9ac9e950b11ebf9cd458;hb=bb89b18cf2ef9975d7374f026ca2f9b719cdf960;hp=3246047ce8677fd1d9ea7f2ad098e4c611911003;hpb=291d201f087974f6e2b717aea983cf6c7b0d67e7;p=rrdtool.git diff --git a/src/rrd_restore.c b/src/rrd_restore.c index 3246047..29a97b3 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.2.12 Copyright by Tobi Oetiker, 1997-2005 + * RRDtool 1.2.13 Copyright by Tobi Oetiker, 1997-2006 ***************************************************************************** * rrd_restore.c creates new rrd from data dumped by rrd_dump.c *****************************************************************************/ @@ -130,10 +130,12 @@ int xml2rrd(char* buf, rrd_t* rrd, char rc){ read_tag(&ptr,"version","%4[0-9]",rrd->stat_head->version); input_version = atoi(rrd->stat_head->version); /* added primitive version checking */ - if (input_version > atoi(RRD_VERSION) ) + if (input_version > atoi(RRD_VERSION) || input_version < 1) { - rrd_set_error("Incompatible file version, detected version %s is bigger than supported version %s\n", + rrd_set_error("Incompatible file version, detected version %s. This is not supported by the version %s restore tool.\n", rrd -> stat_head -> version, RRD_VERSION ); + free(rrd -> stat_head); + rrd->stat_head = NULL; return -1; } /* make sure we output the right version */ @@ -189,8 +191,9 @@ int xml2rrd(char* buf, rrd_t* rrd, char rc){ read_tag(&ptr2,"max","%lf",&(rrd->ds_def[rrd->stat_head->ds_cnt-1].par[DS_max_val].u_val)); } else { /* DST_CDEF */ char buffer[1024]; - read_tag(&ptr2,"cdef","%s",buffer); + read_tag(&ptr2,"cdef","%1000s",buffer); parseCDEF_DS(buffer,rrd,rrd -> stat_head -> ds_cnt - 1); + if (rrd_test_error()) return -1; } read_tag(&ptr2,"last_ds","%30s",rrd->pdp_prep[rrd->stat_head->ds_cnt-1].last_ds);