From 77e98e61ac2768c5a19fb0384d655e78dfa72d41 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 31 Oct 2013 16:28:58 +0100 Subject: handle return value of fread --- dyndhcpd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dyndhcpd.c b/dyndhcpd.c index 7316f5c..e23d3dd 100644 --- a/dyndhcpd.c +++ b/dyndhcpd.c @@ -177,7 +177,7 @@ int main(int argc, char ** argv) { /* read the template */ if ((configfile = fopen(CONFIG_TEMPLATE, "r")) == NULL) { - fprintf(stderr, "Failed reading config template.\n"); + fprintf(stderr, "Failed opening config template for reading.\n"); goto out; } fseek(configfile, 0, SEEK_END); @@ -185,7 +185,10 @@ int main(int argc, char ** argv) { fseek(configfile, 0, SEEK_SET); config = malloc(fsize + 1); - fread(config, fsize, 1, configfile); + if ((fread(config, fsize, 1, configfile)) != 1) { + fprintf(stderr, "Failed reading config template.\n"); + goto out; + } fclose(configfile); config[fsize] = 0; -- cgit v1.2.3-70-g09d2