From: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
To: netfilter-devel@vger.kernel.org
Cc: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Subject: [iptables-nftables PATCH] nft: Calculate properly the target size when parsing it back
Date: Thu, 3 Oct 2013 16:00:59 +0300 [thread overview]
Message-ID: <1380805259-12404-1-git-send-email-tomasz.bursztyka@linux.intel.com> (raw)
Without this, we might allocate less space for the xt_entry_target as we
should, thus leading to a possible bug.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
---
iptables/nft-shared.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/iptables/nft-shared.c b/iptables/nft-shared.c
index c9bde90..25cb177 100644
--- a/iptables/nft-shared.c
+++ b/iptables/nft-shared.c
@@ -292,18 +292,21 @@ void nft_parse_target(struct nft_rule_expr *e, struct nft_rule_expr_iter *iter,
struct xtables_target *target;
struct xt_entry_target *t;
struct nft_family_ops *ops;
+ size_t size;
target = xtables_find_target(targname, XTF_TRY_LOAD);
if (target == NULL)
return;
- t = calloc(1, sizeof(struct xt_entry_target) + tg_len);
+ size = XT_ALIGN(sizeof(struct xt_entry_target)) + tg_len;
+
+ t = calloc(1, size);
if (t == NULL) {
fprintf(stderr, "OOM");
exit(EXIT_FAILURE);
}
memcpy(&t->data, targinfo, tg_len);
- t->u.target_size = tg_len + XT_ALIGN(sizeof(struct xt_entry_target));
+ t->u.target_size = size;
t->u.user.revision = nft_rule_expr_get_u32(e, NFT_EXPR_TG_REV);
strcpy(t->u.user.name, target->name);
--
1.8.3.2
next reply other threads:[~2013-10-03 13:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-03 13:00 Tomasz Bursztyka [this message]
2013-10-03 16:06 ` [iptables-nftables PATCH] nft: Calculate properly the target size when parsing it back 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=1380805259-12404-1-git-send-email-tomasz.bursztyka@linux.intel.com \
--to=tomasz.bursztyka@linux.intel.com \
--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).