Blame SOURCES/0014-Fix-memleak-in-netlink_parse_fwd-error-path.patch

9ff721
From 3578231d0a44c4a7617c046d3ef8b3cb1299c05e Mon Sep 17 00:00:00 2001
9ff721
From: Phil Sutter <phil@nwl.cc>
9ff721
Date: Fri, 12 Oct 2018 12:54:09 +0200
9ff721
Subject: [PATCH] Fix memleak in netlink_parse_fwd() error path
9ff721
9ff721
Make sure allocated 'stmt' is freed before returning to caller.
9ff721
9ff721
Fixes: 30d45266bf38b ("expr: extend fwd statement to support address and family")
9ff721
Signed-off-by: Phil Sutter <phil@nwl.cc>
9ff721
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9ff721
(cherry picked from commit 30541cb66e2de38eea04ab28cb14f298cce9d99f)
9ff721
Signed-off-by: Phil Sutter <psutter@redhat.com>
9ff721
---
9ff721
 src/netlink_delinearize.c | 13 ++++++++-----
9ff721
 1 file changed, 8 insertions(+), 5 deletions(-)
9ff721
9ff721
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
9ff721
index 31d62420d41c8..ae84512c56f3a 100644
9ff721
--- a/src/netlink_delinearize.c
9ff721
+++ b/src/netlink_delinearize.c
9ff721
@@ -1152,9 +1152,11 @@ static void netlink_parse_fwd(struct netlink_parse_ctx *ctx,
9ff721
 		reg2 = netlink_parse_register(nle, NFTNL_EXPR_FWD_SREG_ADDR);
9ff721
 		if (reg2) {
9ff721
 			addr = netlink_get_register(ctx, loc, reg2);
9ff721
-			if (addr == NULL)
9ff721
-				return netlink_error(ctx, loc,
9ff721
-						     "fwd statement has no output expression");
9ff721
+			if (addr == NULL) {
9ff721
+				netlink_error(ctx, loc,
9ff721
+					      "fwd statement has no output expression");
9ff721
+				goto out_err;
9ff721
+			}
9ff721
 
9ff721
 			switch (stmt->fwd.family) {
9ff721
 			case AF_INET:
9ff721
@@ -1166,8 +1168,9 @@ static void netlink_parse_fwd(struct netlink_parse_ctx *ctx,
9ff721
 					      BYTEORDER_BIG_ENDIAN);
9ff721
 				break;
9ff721
 			default:
9ff721
-				return netlink_error(ctx, loc,
9ff721
-						     "fwd statement has no family");
9ff721
+				netlink_error(ctx, loc,
9ff721
+					      "fwd statement has no family");
9ff721
+				goto out_err;
9ff721
 			}
9ff721
 			stmt->fwd.addr = addr;
9ff721
 		}
9ff721
-- 
bacbc8
2.21.0
9ff721