* [iptables-nftables PATCH] nft: Calculate properly the target size when parsing it back
@ 2013-10-03 13:00 Tomasz Bursztyka
2013-10-03 16:06 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Tomasz Bursztyka @ 2013-10-03 13:00 UTC (permalink / raw)
To: netfilter-devel; +Cc: Tomasz Bursztyka
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [iptables-nftables PATCH] nft: Calculate properly the target size when parsing it back
2013-10-03 13:00 [iptables-nftables PATCH] nft: Calculate properly the target size when parsing it back Tomasz Bursztyka
@ 2013-10-03 16:06 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2013-10-03 16:06 UTC (permalink / raw)
To: Tomasz Bursztyka; +Cc: netfilter-devel
On Thu, Oct 03, 2013 at 04:00:59PM +0300, Tomasz Bursztyka wrote:
> Without this, we might allocate less space for the xt_entry_target as we
> should, thus leading to a possible bug.
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-03 16:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-03 13:00 [iptables-nftables PATCH] nft: Calculate properly the target size when parsing it back Tomasz Bursztyka
2013-10-03 16:06 ` Pablo Neira Ayuso
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).