]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: fix wrong target size
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Thu, 3 Oct 2013 13:00:59 +0000 (16:00 +0300)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 30 Dec 2013 22:50:50 +0000 (23:50 +0100)
The allocated area was not aligned.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/nft-shared.c

index c9bde90bcfc38cb02be8f9bc8b32e8fa2cc2a4b0..25cb1772b5ea009b86c9a4ae72e7a9a53ec7e5e3 100644 (file)
@@ -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);