]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
Fix memleak in netlink_parse_fwd() error path
authorPhil Sutter <phil@nwl.cc>
Fri, 12 Oct 2018 10:54:09 +0000 (12:54 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 15 Oct 2018 11:37:51 +0000 (13:37 +0200)
Make sure allocated 'stmt' is freed before returning to caller.

Fixes: 30d45266bf38b ("expr: extend fwd statement to support address and family")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink_delinearize.c

index 0a6ebe05ca7ca7a05e111c89f639d5efa2d73493..cd058850f4df079fd977c316823461f69ee9bb4d 100644 (file)
@@ -1227,9 +1227,11 @@ static void netlink_parse_fwd(struct netlink_parse_ctx *ctx,
                reg2 = netlink_parse_register(nle, NFTNL_EXPR_FWD_SREG_ADDR);
                if (reg2) {
                        addr = netlink_get_register(ctx, loc, reg2);
-                       if (addr == NULL)
-                               return netlink_error(ctx, loc,
-                                                    "fwd statement has no output expression");
+                       if (addr == NULL) {
+                               netlink_error(ctx, loc,
+                                             "fwd statement has no output expression");
+                               goto out_err;
+                       }
 
                        switch (stmt->fwd.family) {
                        case AF_INET:
@@ -1241,8 +1243,9 @@ static void netlink_parse_fwd(struct netlink_parse_ctx *ctx,
                                              BYTEORDER_BIG_ENDIAN);
                                break;
                        default:
-                               return netlink_error(ctx, loc,
-                                                    "fwd statement has no family");
+                               netlink_error(ctx, loc,
+                                             "fwd statement has no family");
+                               goto out_err;
                        }
                        stmt->fwd.addr = addr;
                }