Be a little more rigorous when parsing
authoraland <aland>
Wed, 16 May 2007 07:49:49 +0000 (07:49 +0000)
committeraland <aland>
Wed, 16 May 2007 07:49:49 +0000 (07:49 +0000)
This fixes Coverity bug #48

src/main/files.c

index 389262b..c1512d4 100644 (file)
@@ -81,7 +81,7 @@ int pairlist_read(const char *file, PAIR_LIST **list, int complain)
        PAIR_LIST **last = &pl;
        int lineno = 0;
        int old_lineno = 0;
-       LRAD_TOKEN parsecode;
+       LRAD_TOKEN parsecode, token;
        char newfile[8192];
 
        /*
@@ -139,7 +139,18 @@ parse_again:
                        }
 
                        ptr = buffer;
-                       getword(&ptr, entry, sizeof(entry));
+                       token = getword(&ptr, entry, sizeof(entry));
+                       if (token == T_EOL) break;
+
+                       if ((token != T_BARE_WORD) &&
+                           (token != T_DOUBLE_QUOTED_STRING) &&
+                           (token != T_SINGLE_QUOTED_STRING)) {
+                               radlog(L_ERR, "%s[%d]: Unexpected text at start of entry",
+                                      file, lineno);
+                               fclose(fp);
+                               return -1;
+                       }
+
 
                        /*
                         *      Include another file if we see