68 строки
2.1 KiB
Diff
68 строки
2.1 KiB
Diff
From deb82693c3173f2088ac2a24218085b0b2dc573d Mon Sep 17 00:00:00 2001
|
|
From: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
Date: Thu, 2 Jan 2020 16:37:31 +0100
|
|
Subject: [PATCH] scanner: incorrect error reporting after file inclusion
|
|
|
|
scanner_pop_buffer() incorrectly sets the current input descriptor. The
|
|
state->indesc_idx field actually stores the number of input descriptors
|
|
in the stack, decrement it and then update the current input descriptor
|
|
accordingly.
|
|
|
|
Fixes: 60e917fa7cb5 ("src: dynamic input_descriptor allocation")
|
|
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1383
|
|
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
(cherry picked from commit 4441c0233cbcb74b08a53720557e76bf0b26c998)
|
|
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
---
|
|
src/scanner.l | 22 +++++++++++++++++++---
|
|
1 file changed, 19 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/scanner.l b/src/scanner.l
|
|
index d32adf4897ae1..25db4d3f24eec 100644
|
|
--- a/src/scanner.l
|
|
+++ b/src/scanner.l
|
|
@@ -664,12 +664,29 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
|
|
|
|
%%
|
|
|
|
+static void scanner_push_indesc(struct parser_state *state,
|
|
+ struct input_descriptor *indesc)
|
|
+{
|
|
+ state->indescs[state->indesc_idx] = indesc;
|
|
+ state->indesc = state->indescs[state->indesc_idx++];
|
|
+}
|
|
+
|
|
+static void scanner_pop_indesc(struct parser_state *state)
|
|
+{
|
|
+ state->indesc_idx--;
|
|
+
|
|
+ if (state->indesc_idx > 0)
|
|
+ state->indesc = state->indescs[state->indesc_idx - 1];
|
|
+ else
|
|
+ state->indesc = NULL;
|
|
+}
|
|
+
|
|
static void scanner_pop_buffer(yyscan_t scanner)
|
|
{
|
|
struct parser_state *state = yyget_extra(scanner);
|
|
|
|
yypop_buffer_state(scanner);
|
|
- state->indesc = state->indescs[--state->indesc_idx];
|
|
+ scanner_pop_indesc(state);
|
|
}
|
|
|
|
static void scanner_push_file(struct nft_ctx *nft, void *scanner,
|
|
@@ -690,8 +707,7 @@ static void scanner_push_file(struct nft_ctx *nft, void *scanner,
|
|
indesc->name = xstrdup(filename);
|
|
init_pos(indesc);
|
|
|
|
- state->indescs[state->indesc_idx] = indesc;
|
|
- state->indesc = state->indescs[state->indesc_idx++];
|
|
+ scanner_push_indesc(state, indesc);
|
|
list_add_tail(&indesc->list, &state->indesc_list);
|
|
}
|
|
|
|
--
|
|
2.28.0
|
|
|