From patchwork Tue Aug 22 17:05:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 804576 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xcH4X1Hpxz9s65 for ; Wed, 23 Aug 2017 03:05:32 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751840AbdHVRFa (ORCPT ); Tue, 22 Aug 2017 13:05:30 -0400 Received: from mail.us.es ([193.147.175.20]:40952 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751679AbdHVRF3 (ORCPT ); Tue, 22 Aug 2017 13:05:29 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 3A2CCD25EE for ; Tue, 22 Aug 2017 19:05:13 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 2894DA7F30 for ; Tue, 22 Aug 2017 19:05:13 +0200 (CEST) Received: by antivirus1-rhel7.int (Postfix, from userid 99) id 1CFE5A8272; Tue, 22 Aug 2017 19:05:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on antivirus1-rhel7.int X-Spam-Level: X-Spam-Status: No, score=-108.2 required=7.5 tests=ALL_TRUSTED,BAYES_50, SMTPAUTH_US2,USER_IN_WHITELIST autolearn=disabled version=3.4.1 Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id F0C0DC8813; Tue, 22 Aug 2017 19:05:10 +0200 (CEST) Received: from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int (F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); Tue, 22 Aug 2017 19:05:10 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int) Received: from salvia.here (unknown [31.4.198.213]) (Authenticated sender: pneira@us.es) by entrada.int (Postfix) with ESMTPA id 801DE4265A20; Tue, 22 Aug 2017 19:05:01 +0200 (CEST) X-SMTPAUTHUS: auth mail.us.es From: Pablo Neira Ayuso 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 Message-Id: <1503421511-17814-3-git-send-email-pablo@netfilter.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1503421511-17814-1-git-send-email-pablo@netfilter.org> References: <1503421511-17814-1-git-send-email-pablo@netfilter.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Not a global variable anymore. Signed-off-by: Pablo Neira Ayuso --- 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 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);