if ((rrd_file = fopen(file_name,"wb")) == NULL ) {
rrd_set_error("creating '%s': %s",file_name, rrd_strerror(errno));
free(rrd->stat_head);
+ rrd->stat_head = NULL;
free(rrd->ds_def);
+ rrd->ds_def = NULL;
free(rrd->rra_def);
+ rrd->rra_def = NULL;
return(-1);
}
if (strncmp(rrd->stat_head->cookie,RRD_COOKIE,4) != 0){
rrd_set_error("'%s' is not an RRD file",file_name);
free(rrd->stat_head);
+ rrd->stat_head = NULL;
fclose(*in_file);
return(-1);}
if (rrd->stat_head->float_cookie != FLOAT_COOKIE){
rrd_set_error("This RRD was created on other architecture");
free(rrd->stat_head);
+ rrd->stat_head = NULL;
fclose(*in_file);
return(-1);}
rrd_set_error("can't handle RRD file version %s",
rrd->stat_head->version);
free(rrd->stat_head);
+ rrd->stat_head = NULL;
fclose(*in_file);
return(-1);}
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 */