]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
libnftables: don't crash when no commands are specified
authorHarsha Sharma <harshasharmaiitr@gmail.com>
Sat, 3 Mar 2018 08:03:58 +0000 (13:33 +0530)
committerFlorian Westphal <fw@strlen.de>
Sat, 3 Mar 2018 09:13:06 +0000 (10:13 +0100)
For e.g.  nft -c "  "
Without this patch it segfaults.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
src/libnftables.c

index c86d89477e778ae6aa483d1026fa71966bc20b40..1d1975e99817f5b6e4936f5f991cbf5f06811466 100644 (file)
@@ -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));