From: Jonathan McDowell Date: Tue, 22 Jul 2014 11:38:33 +0000 (+0100) Subject: Bail out if we get errors reading the config file X-Git-Tag: onak-0.4.3~13 X-Git-Url: https://the.earth.li/gitweb/?a=commitdiff_plain;h=5bb7517b14fb7f1e354228cc3ccfe2a878a9999e;p=onak.git Bail out if we get errors reading the config file --- 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 {