From 5bb7517b14fb7f1e354228cc3ccfe2a878a9999e Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Tue, 22 Jul 2014 12:38:33 +0100 Subject: [PATCH] Bail out if we get errors reading the config file --- onak-conf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/onak-conf.c b/onak-conf.c index e3085e1..ccad3c5 100644 --- a/onak-conf.c +++ b/onak-conf.c @@ -118,7 +118,12 @@ void readconfig(const char *configfile) { conffile = fopen(configfile, "r"); } if (conffile != NULL) { - fgets(curline, 1023, conffile); + if (!fgets(curline, 1023, conffile)) { + logthing(LOGTHING_CRITICAL, + "Problem reading configuration file."); + fclose(conffile); + return; + } while (!feof(conffile)) { for (i = strlen(curline) - 1; @@ -203,7 +208,12 @@ void readconfig(const char *configfile) { "Unknown config line: %s", curline); } - fgets(curline, 1023, conffile); + if (!fgets(curline, 1023, conffile) && + !feof(conffile)) { + logthing(LOGTHING_CRITICAL, + "Problem reading configuration file."); + break; + } } fclose(conffile); } else { -- 2.39.5