netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: phil@nwl.cc, eric@regit.org
Subject: [PATCH nft 2/6] src: add maximum number of parser errors to struct nft_ctx
Date: Tue, 22 Aug 2017 19:05:07 +0200	[thread overview]
Message-ID: <1503421511-17814-3-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1503421511-17814-1-git-send-email-pablo@netfilter.org>

Not a global variable anymore.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 include/nftables.h | 2 +-
 src/main.c         | 2 +-
 src/parser_bison.y | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/nftables.h b/include/nftables.h
index 8399b1ae68f9..8858ad605516 100644
--- a/include/nftables.h
+++ b/include/nftables.h
@@ -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 {
diff --git a/src/main.c b/src/main.c
index eb0dfb02fd15..fc44b186d5f0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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 18c0f0aa9600..7c00f4f099f7 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);
-- 
2.1.4



  parent reply	other threads:[~2017-08-22 17:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 17:05 [PATCH nft 0/6] Remove more global variables Pablo Neira Ayuso
2017-08-22 17:05 ` [PATCH nft 1/6] src: add include_paths to struct nft_ctx Pablo Neira Ayuso
2017-08-22 17:05 ` Pablo Neira Ayuso [this message]
2017-08-22 17:05 ` [PATCH nft 3/6] src: remove ifdef DEBUG pollution Pablo Neira Ayuso
2017-08-22 17:05 ` [PATCH nft 4/6] src: add struct mnl_ctx Pablo Neira Ayuso
2017-08-22 17:05 ` [PATCH nft 5/6] mnl: pass struct netlink_ctx to mnl_nft_socket_sendmsg() Pablo Neira Ayuso
2017-08-22 17:05 ` [PATCH nft 6/6] src: add debugging mask to context structure Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1503421511-17814-3-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=eric@regit.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=phil@nwl.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).