From 82e732c6e6ae33cd9376fb016fb999704db57674 Mon Sep 17 00:00:00 2001 From: Harsha Sharma Date: Sat, 3 Mar 2018 13:33:58 +0530 Subject: libnftables: don't crash when no commands are specified For e.g. nft -c " " Without this patch it segfaults. Signed-off-by: Harsha Sharma Signed-off-by: Florian Westphal --- src/libnftables.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libnftables.c b/src/libnftables.c index c86d8947..1d1975e9 100644 --- a/src/libnftables.c +++ b/src/libnftables.c @@ -30,6 +30,9 @@ static int nft_netlink(struct nft_ctx *nft, bool batch_supported = netlink_batch_supported(nf_sock, &seqnum); int ret = 0; + if (list_empty(&state->cmds)) + return 0; + batch = mnl_batch_init(); batch_seqnum = mnl_batch_begin(batch, mnl_seqnum_alloc(&seqnum)); -- cgit v1.2.3