diff mbox

[nft,2/4] netlink: Fix segfault when using --echo flag

Message ID 20170814234305.2829-3-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

Phil Sutter Aug. 14, 2017, 11:43 p.m. UTC
Commit 07b45939972eb ("src: introduce struct nft_cache") added cache
pointer to struct netlink_mon_handler and the code assumes it is never
NULL. Therefore initialize it in the dummy version of
netlink_mon_handler in netlink_echo_callback().

Fixes: b99c4d072d996 ("Implement --echo option")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/netlink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Pablo Neira Ayuso Aug. 15, 2017, 10:25 a.m. UTC | #1
On Tue, Aug 15, 2017 at 01:43:03AM +0200, Phil Sutter wrote:
> Commit 07b45939972eb ("src: introduce struct nft_cache") added cache
> pointer to struct netlink_mon_handler and the code assumes it is never
> NULL. Therefore initialize it in the dummy version of
> netlink_mon_handler in netlink_echo_callback().

Also applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/netlink.c b/src/netlink.c
index 8aef8d9ab4070..f631c26b2b9ca 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -3075,12 +3075,14 @@  static int netlink_events_cb(const struct nlmsghdr *nlh, void *data)
 
 int netlink_echo_callback(const struct nlmsghdr *nlh, void *data)
 {
+	struct netlink_ctx *ctx = data;
 	struct netlink_mon_handler echo_monh = {
 		.format = NFTNL_OUTPUT_DEFAULT,
-		.ctx = data,
+		.ctx = ctx,
 		.loc = &netlink_location,
 		.monitor_flags = 0xffffffff,
 		.cache_needed = true,
+		.cache = ctx->cache,
 	};
 
 	if (!echo_monh.ctx->octx->echo)