]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: add maximum number of parser errors to struct nft_ctx
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 22 Aug 2017 16:09:12 +0000 (18:09 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 23 Aug 2017 21:42:33 +0000 (23:42 +0200)
Not a global variable anymore.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/nftables.h
src/main.c
src/parser_bison.y

index 8399b1ae68f9cd237309c58519278309f18ce22e..8858ad605516dde1d7d2e94ab4c8dcb56d5a1a4d 100644 (file)
@@ -41,12 +41,12 @@ struct nft_cache {
 struct nft_ctx {
        const char              *include_paths[INCLUDE_PATHS_MAX];
        unsigned int            num_include_paths;
+       unsigned int            parser_max_errors;
        struct output_ctx       output;
        bool                    check;
        struct nft_cache        cache;
 };
 
-extern unsigned int max_errors;
 extern unsigned int debug_level;
 
 enum nftables_exit_codes {
index eb0dfb02fd150f4cff1fbc4fa22baadc8ed7330a..fc44b186d5f0b8048b79803aa6d025ce98e7790e 100644 (file)
@@ -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)
index 0a56d12cf594b6b654476a655ffdae97683eb2d9..a187d0981ae3f159d9093a0f48068b30d5c3c49c 100644 (file)
@@ -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);