]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
rule: fix leaks in NFTNL_RULE_USERDATA
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 15 Apr 2016 10:29:42 +0000 (12:29 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 15 Apr 2016 10:51:51 +0000 (12:51 +0200)
Fix leaks in nftnl_rule_free() and nftnl_rule_set_data().

Reported-by: Carlos Falgueras GarcĂ­a <carlosfg@riseup.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c

index 3a32bf691d53ae016dec56317020275e286698de..9c0912711881d679b7db907f02d554e38964c14b 100644 (file)
@@ -75,6 +75,8 @@ void nftnl_rule_free(struct nftnl_rule *r)
                xfree(r->table);
        if (r->chain != NULL)
                xfree(r->chain);
+       if (r->user.data != NULL)
+               xfree(r->user.data);
 
        xfree(r);
 }
@@ -162,6 +164,9 @@ void nftnl_rule_set_data(struct nftnl_rule *r, uint16_t attr,
                r->position = *((uint64_t *)data);
                break;
        case NFTNL_RULE_USERDATA:
+               if (r->user.data != NULL)
+                       xfree(r->user.data);
+
                r->user.data = (void *)data;
                r->user.len = data_len;
                break;