]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 326] handle MAXTOKEN overflow better.
authorHarlan Stenn <stenn@ntp.org>
Fri, 6 Aug 2004 03:33:23 +0000 (23:33 -0400)
committerHarlan Stenn <stenn@ntp.org>
Fri, 6 Aug 2004 03:33:23 +0000 (23:33 -0400)
bk: 4112fc03JfeBlECUKqStJV3C8FopRg

ntpd/ntp_config.c

index 1f95f46e6f0f08b821a4ed5c68af0b36d0c134d4..a22b4c1bda19e8777e1c53733253cabd86f62001 100644 (file)
@@ -1951,9 +1951,17 @@ gettokens_netinfo (
                                if (ISEOL(*tokens)) break;
                        }
                }
-               *ntokens = ntok + 1;
-               
-               config->val_index++;
+
+               if (ntok == MAXTOKENS) {
+                       /* HMS: chomp it to lose the EOL? */
+                       msyslog(LOG_ERR,
+                           "gettokens_netinfo: too many tokens.  Ignoring: %s",
+                           tokens);
+               } else {
+                       *ntokens = ntok + 1;
+               }
+
+               config->val_index++;    /* HMS: Should this be in the 'else'? */
 
                return keywords[prop_index].keytype;
        }
@@ -2023,13 +2031,22 @@ gettokens (
                }
        }
 
-       /*
-        * Return the match
-        */
-       *ntokens = ntok + 1;
-       ntok = matchkey(tokenlist[0], keywords, 1);
-       if (ntok == CONFIG_UNKNOWN)
-               goto again;
+       if (ntok == MAXTOKENS) {
+               --ntok;
+               /* HMS: chomp it to lose the EOL? */
+               msyslog(LOG_ERR,
+                   "gettokens: too many tokens on the line. Ignoring %s",
+                   cp);
+       } else {
+               /*
+                * Return the match
+                */
+               *ntokens = ntok + 1;
+               ntok = matchkey(tokenlist[0], keywords, 1);
+               if (ntok == CONFIG_UNKNOWN)
+                       goto again;
+       }
+
        return ntok;
 }