Be a little more rigorous in the parser.
authoraland <aland>
Wed, 16 May 2007 07:51:24 +0000 (07:51 +0000)
committeraland <aland>
Wed, 16 May 2007 07:51:24 +0000 (07:51 +0000)
This fixes Coverity bug #48

src/main/files.c

index d8caf88..a1819bf 100644 (file)
@@ -71,7 +71,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];
 
        /*
@@ -129,7 +129,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