From: oetiker Date: Sat, 14 May 2005 15:07:35 +0000 (+0000) Subject: check cookie read for success X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8eb3585d8542905c0d968c3f4c5035657db20cdd;p=rrdtool-all.git check cookie read for success git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@557 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c index ff68ca42..7b1a0f1d 100644 --- a/program/src/rrd_open.c +++ b/program/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 ... */