summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/nftables.h1
-rw-r--r--include/parser.h1
-rw-r--r--src/main.c3
-rw-r--r--src/parser.y7
4 files changed, 10 insertions, 2 deletions
diff --git a/include/nftables.h b/include/nftables.h
index 5a000870..7f3968d4 100644
--- a/include/nftables.h
+++ b/include/nftables.h
@@ -24,6 +24,7 @@ enum debug_level {
#define INCLUDE_PATHS_MAX 16
+extern unsigned int max_errors;
extern unsigned int numeric_output;
extern unsigned int handle_output;
extern unsigned int debug_level;
diff --git a/include/parser.h b/include/parser.h
index f5dd6f4b..7a1c2dbe 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -19,6 +19,7 @@ struct parser_state {
unsigned int indesc_idx;
struct list_head *msgs;
+ unsigned int nerrs;
struct scope top_scope;
struct scope *scopes[SCOPE_NEST_MAX];
diff --git a/src/main.c b/src/main.c
index 28ce1aa6..2320a826 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,6 +26,7 @@
#include <erec.h>
#include <mnl.h>
+unsigned int max_errors = 10;
unsigned int numeric_output;
unsigned int handle_output;
#ifdef DEBUG
@@ -219,7 +220,7 @@ int nft_run(void *scanner, struct parser_state *state, struct list_head *msgs)
int ret = 0;
ret = nft_parse(scanner, state);
- if (ret != 0)
+ if (ret != 0 || state->nerrs > 0)
return -1;
memset(&ctx, 0, sizeof(ctx));
diff --git a/src/parser.y b/src/parser.y
index fa33b570..0dad036c 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -518,6 +518,12 @@ common_block : INCLUDE QUOTED_STRING stmt_seperator
symbol_bind(current_scope(state), $2, $4);
xfree($2);
}
+ | error stmt_seperator
+ {
+ if (++state->nerrs == max_errors)
+ YYABORT;
+ yyerrok;
+ }
;
line : common_block { $$ = NULL; }
@@ -542,7 +548,6 @@ line : common_block { $$ = NULL; }
YYACCEPT;
}
- | base_cmd error { $$ = $1; }
;
base_cmd : /* empty */ add_cmd { $$ = $1; }