From 4e09a380ce1114b1d2f05f0506c19d6a2d7a7e0b Mon Sep 17 00:00:00 2001 From: Marek Schimara Date: Fri, 17 Jun 2016 13:40:08 +0200 Subject: [PATCH] src/rrd_cgi.c: fix Coverity CID#13625 Truncated stdio return value --- src/rrd_cgi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rrd_cgi.c b/src/rrd_cgi.c index 4e527218..d1ebbb64 100644 --- a/src/rrd_cgi.c +++ b/src/rrd_cgi.c @@ -418,7 +418,12 @@ static int readfile( totalcnt = (ftell(input) + 1) / sizeof(char) - offset; if (totalcnt < MEMBLK) totalcnt = MEMBLK; /* sanitize */ - fseek(input, offset * sizeof(char), SEEK_SET); + if (fseek(input, offset * sizeof(char), SEEK_SET) == -1) + { + rrd_set_error("fseek() failed on %s: %s", file_name, rrd_strerror(errno)); + fclose(input); + return (-1); + } } if (((*buffer) = (char *) malloc((totalcnt + 4) * sizeof(char))) == NULL) { perror("Allocate Buffer:"); -- 2.47.2