From: oetiker Date: Sat, 14 May 2005 15:07:35 +0000 (+0000) Subject: check cookie read for success X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5e060d8a49301fee5681969c8771473dd024cb98;p=rrdtool.git check cookie read for success git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@557 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_open.c b/src/rrd_open.c index ff68ca4..7b1a0f1 100644 --- a/src/rrd_open.c +++ b/src/rrd_open.c @@ -101,11 +101,17 @@ rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr) if ((MYVAR = malloc(sizeof(MYVART) * MYCNT)) == NULL) {\ rrd_set_error("" #MYVAR " malloc"); \ fclose(*in_file); \ - return (-1); } \ + return (-1); } \ fread(MYVAR,sizeof(MYVART),MYCNT, *in_file); MYFREAD(rrd->stat_head, stat_head_t, 1) + /* lets see if the first read worked */ + if (ferror( *in_file )){ + rrd_set_error("reading the cookie off %s faild",file_name); + fclose(*in_file); + return(-1); + } version = atoi(rrd->stat_head->version); /* lets do some test if we are on track ... */