From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 1/2] netlink_delinearize: release expressions in context registers
Date: Mon, 10 Jun 2019 17:34:48 +0200 [thread overview]
Message-ID: <20190610153449.9199-1-pablo@netfilter.org> (raw)
netlink_release_registers() needs to go a bit further to release the
expressions in the register array. This should be safe since
netlink_get_register() clones expressions in the context registers.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/netlink.h | 4 +++-
src/netlink_delinearize.c | 6 +++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/netlink.h b/include/netlink.h
index a20ebbe4740c..0c08b1abbf6a 100644
--- a/include/netlink.h
+++ b/include/netlink.h
@@ -14,12 +14,14 @@
#include <rule.h>
+#define MAX_REGS (1 + NFT_REG32_15 - NFT_REG32_00)
+
struct netlink_parse_ctx {
struct list_head *msgs;
struct table *table;
struct rule *rule;
struct stmt *stmt;
- struct expr *registers[1 + NFT_REG32_15 - NFT_REG32_00 + 1];
+ struct expr *registers[MAX_REGS + 1];
unsigned int debug_mask;
};
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index c018e78b0292..a1c775e679e4 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -63,7 +63,7 @@ static void netlink_set_register(struct netlink_parse_ctx *ctx,
enum nft_registers reg,
struct expr *expr)
{
- if (reg == NFT_REG_VERDICT || reg > 1 + NFT_REG32_15 - NFT_REG32_00) {
+ if (reg == NFT_REG_VERDICT || reg > MAX_REGS) {
netlink_error(ctx, &expr->location,
"Invalid destination register %u", reg);
expr_free(expr);
@@ -82,7 +82,7 @@ static struct expr *netlink_get_register(struct netlink_parse_ctx *ctx,
{
struct expr *expr;
- if (reg == NFT_REG_VERDICT || reg > 1 + NFT_REG32_15 - NFT_REG32_00) {
+ if (reg == NFT_REG_VERDICT || reg > MAX_REGS) {
netlink_error(ctx, loc, "Invalid source register %u", reg);
return NULL;
}
@@ -98,7 +98,7 @@ static void netlink_release_registers(struct netlink_parse_ctx *ctx)
{
int i;
- for (i = 0; i <= NFT_REG_MAX; i++)
+ for (i = 0; i < MAX_REGS; i++)
expr_free(ctx->registers[i]);
}
--
2.11.0
next reply other threads:[~2019-06-10 15:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-10 15:34 Pablo Neira Ayuso [this message]
2019-06-10 15:34 ` [PATCH nft 2/2] netlink_delinearize: release expression before calling netlink_parse_concat_expr() 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=20190610153449.9199-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
/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).