aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2013-10-31 16:28:58 +0100
committerGravatar Christian Hesse <mail@eworm.de>2013-10-31 16:28:58 +0100
commit77e98e61ac2768c5a19fb0384d655e78dfa72d41 (patch)
tree90db4645adbba48fe70f913387bd277fccb4a1bd
parentf0ec293fee4f149e0234d0bfccdd6189145370e8 (diff)
downloaddyndhcpd-77e98e61ac2768c5a19fb0384d655e78dfa72d41.tar.gz
dyndhcpd-77e98e61ac2768c5a19fb0384d655e78dfa72d41.tar.zst
handle return value of fread
-rw-r--r--dyndhcpd.c7
1 files 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;