]> the.earth.li Git - onak.git/commitdiff
Fix parsing of empty config file lines.
authorJonathan McDowell <noodles@earth.li>
Wed, 15 Dec 2004 15:27:44 +0000 (15:27 +0000)
committerJonathan McDowell <noodles@earth.li>
Wed, 15 Dec 2004 15:27:44 +0000 (15:27 +0000)
Fred Strauss reported a problem with parsing empty lines in the config
file; we weren't checking if the line was empty before stripping
trailing white space. We do now.

onak-conf.c

index 81d7bdf97cc978ff2f271643a8dccb61ebf710ad..f97197cf72694c58167d53ade6b1bb2e205f78f8 100644 (file)
@@ -60,9 +60,11 @@ void readconfig(const char *configfile) {
                fgets(curline, 1023, conffile);
 
                while (!feof(conffile)) {
-               for (i = strlen(curline) - 1; isspace(curline[i]); i--) {
-                       curline[i] = 0;
-               }
+                       for (i = strlen(curline) - 1;
+                                       i >= 0 && isspace(curline[i]);
+                                       i--) {
+                               curline[i] = 0;
+                       }
 
                if (curline[0] == '#' || curline[0] == 0) {
                        /*