]> the.earth.li Git - onak.git/commitdiff
Bail out if we get errors reading the config file
authorJonathan McDowell <noodles@earth.li>
Tue, 22 Jul 2014 11:38:33 +0000 (12:38 +0100)
committerJonathan McDowell <noodles@earth.li>
Tue, 22 Jul 2014 11:39:02 +0000 (12:39 +0100)
onak-conf.c

index e3085e1996be9e1fa6ec7690ea8f70fdf7e10951..ccad3c5a78f800dde720e8562456fab44d119a19 100644 (file)
@@ -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 {