diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-08-22 18:09:12 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-08-23 23:42:33 +0200 |
commit | 4dedecf4d64ef64f7f86efeeed117be931005282 (patch) | |
tree | c944c2079722c37cb529eb609665b152bea60ed4 /src | |
parent | af038fcf186496ba07fe1cf59263b6741a0988da (diff) |
src: add maximum number of parser errors to struct nft_ctx
Not a global variable anymore.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/parser_bison.y | 6 |
2 files changed, 4 insertions, 4 deletions
@@ -29,7 +29,6 @@ #include <cli.h> static struct nft_ctx nft; -unsigned int max_errors = 10; #ifdef DEBUG unsigned int debug_level; #endif @@ -295,6 +294,7 @@ static void nft_ctx_init(struct nft_ctx *nft) { nft->include_paths[0] = DEFAULT_INCLUDE_PATH; nft->num_include_paths = 1; + nft->parser_max_errors = 10; } int main(int argc, char * const *argv) diff --git a/src/parser_bison.y b/src/parser_bison.y index 0a56d12c..a187d098 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -692,7 +692,7 @@ input : /* empty */ list_add_tail(&$2->list, &list); if (cmd_evaluate(&state->ectx, $2) < 0) { - if (++state->nerrs == max_errors) + if (++state->nerrs == nft->parser_max_errors) YYABORT; } else list_splice_tail(&list, &state->cmds); @@ -731,7 +731,7 @@ common_block : INCLUDE QUOTED_STRING stmt_seperator } | error stmt_seperator { - if (++state->nerrs == max_errors) + if (++state->nerrs == nft->parser_max_errors) YYABORT; yyerrok; } @@ -758,7 +758,7 @@ line : common_block { $$ = NULL; } list_add_tail(&$1->list, &list); if (cmd_evaluate(&state->ectx, $1) < 0) { - if (++state->nerrs == max_errors) + if (++state->nerrs == nft->parser_max_errors) YYABORT; } else list_splice_tail(&list, &state->cmds); |