]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink_delinearize: stmt and expr error path memleaks
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 12 Jul 2021 16:10:57 +0000 (18:10 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 13 Jul 2021 12:55:20 +0000 (14:55 +0200)
Use stmt_free() and expr_free() to release these objects.

Fixes: 671851617c8d ("netlink_delinearize: Fix resource leaks")
Fixes: 3a8640672978 ("src: hash: support of symmetric hash")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink_delinearize.c

index 71b69f622a7660da6f37157b9d8bfe6d9fae5b82..fd994b8bdde673ae154ff906fc3cf2557c9e1512 100644 (file)
@@ -637,7 +637,7 @@ static void netlink_parse_exthdr(struct netlink_parse_ctx *ctx,
                sreg = netlink_parse_register(nle, NFTNL_EXPR_EXTHDR_SREG);
                val = netlink_get_register(ctx, loc, sreg);
                if (val == NULL) {
-                       xfree(expr);
+                       expr_free(expr);
                        return netlink_error(ctx, loc,
                                             "exthdr statement has no expression");
                }
@@ -679,7 +679,7 @@ static void netlink_parse_hash(struct netlink_parse_ctx *ctx,
                len = nftnl_expr_get_u32(nle,
                                         NFTNL_EXPR_HASH_LEN) * BITS_PER_BYTE;
                if (hexpr->len < len) {
-                       xfree(hexpr);
+                       expr_free(hexpr);
                        hexpr = netlink_parse_concat_expr(ctx, loc, sreg, len);
                        if (hexpr == NULL)
                                goto out_err;
@@ -691,7 +691,7 @@ static void netlink_parse_hash(struct netlink_parse_ctx *ctx,
        netlink_set_register(ctx, dreg, expr);
        return;
 out_err:
-       xfree(expr);
+       expr_free(expr);
 }
 
 static void netlink_parse_fib(struct netlink_parse_ctx *ctx,
@@ -1183,7 +1183,7 @@ static void netlink_parse_nat(struct netlink_parse_ctx *ctx,
        ctx->stmt = stmt;
        return;
 out_err:
-       xfree(stmt);
+       stmt_free(stmt);
 }
 
 static void netlink_parse_synproxy(struct netlink_parse_ctx *ctx,
@@ -1247,7 +1247,7 @@ static void netlink_parse_tproxy(struct netlink_parse_ctx *ctx,
        ctx->stmt = stmt;
        return;
 err:
-       xfree(stmt);
+       stmt_free(stmt);
 }
 
 static void netlink_parse_masq(struct netlink_parse_ctx *ctx,
@@ -1294,7 +1294,7 @@ static void netlink_parse_masq(struct netlink_parse_ctx *ctx,
        ctx->stmt = stmt;
        return;
 out_err:
-       xfree(stmt);
+       stmt_free(stmt);
 }
 
 static void netlink_parse_redir(struct netlink_parse_ctx *ctx,
@@ -1345,7 +1345,7 @@ static void netlink_parse_redir(struct netlink_parse_ctx *ctx,
        ctx->stmt = stmt;
        return;
 out_err:
-       xfree(stmt);
+       stmt_free(stmt);
 }
 
 static void netlink_parse_dup(struct netlink_parse_ctx *ctx,
@@ -1398,7 +1398,7 @@ static void netlink_parse_dup(struct netlink_parse_ctx *ctx,
        ctx->stmt = stmt;
        return;
 out_err:
-       xfree(stmt);
+       stmt_free(stmt);
 }
 
 static void netlink_parse_fwd(struct netlink_parse_ctx *ctx,
@@ -1460,7 +1460,7 @@ static void netlink_parse_fwd(struct netlink_parse_ctx *ctx,
        ctx->stmt = stmt;
        return;
 out_err:
-       xfree(stmt);
+       stmt_free(stmt);
 }
 
 static void netlink_parse_queue(struct netlink_parse_ctx *ctx,
@@ -1623,7 +1623,7 @@ out_err:
        list_for_each_entry_safe(dstmt, next, &dynset_parse_ctx.stmt_list, list)
                stmt_free(dstmt);
 
-       xfree(expr);
+       expr_free(expr);
 }
 
 static void netlink_parse_objref(struct netlink_parse_ctx *ctx,