]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
main: Fix for return of uninitialized variable in nft_run_cmd_from_filename()
authorPhil Sutter <phil@nwl.cc>
Thu, 21 Sep 2017 13:10:39 +0000 (15:10 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 27 Sep 2017 12:11:58 +0000 (14:11 +0200)
If scanner_read_file() failed, the function would return an
uninitialized value.

Fixes: 3db28321b64a6 ("src: add nft_run_cmd_*() functions")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/main.c

index 702ef30237b3bb26161074b4f0be155fa206e862..8e7b586d347ccaa4bd95b75619240ed44104d4bd 100644 (file)
@@ -351,8 +351,10 @@ static int nft_run_cmd_from_filename(struct nft_ctx *nft, const char *filename)
 
        parser_init(nft->nf_sock, &nft->cache, &state, &msgs, nft->debug_mask);
        scanner = scanner_init(&state);
-       if (scanner_read_file(scanner, filename, &internal_location) < 0)
+       if (scanner_read_file(scanner, filename, &internal_location) < 0) {
+               rc = NFT_EXIT_FAILURE;
                goto err;
+       }
 
        if (nft_run(nft, nft->nf_sock, scanner, &state, &msgs) != 0)
                rc = NFT_EXIT_FAILURE;