diff options
author | Phil Sutter <phil@nwl.cc> | 2017-10-04 15:59:32 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-10-06 14:30:56 +0200 |
commit | 881fad86fa4942571c74cdfa89831a2cd25dbe16 (patch) | |
tree | 8ddd4a0fde3e6306ad63884c691f02641b1dd255 /src/main.c | |
parent | b873a1731d2481851c57eab3dcf3e719e9d45b50 (diff) |
evaluate: Fix debug output
When introducing output_fp, debug output in src/evaluate.c was not
adjusted and therefore broke.
This patch restores eval debug output by applying the following changes:
- Change erec_print() and erec_print_list() to take a struct output_ctx
pointer as first argument and use output_fp field as destination to
print to.
- Drop octx_debug_dummy variable and instead use octx pointer from
struct eval_ctx for debug output.
- Add missing calls to erec_destroy() in eval debug output which should
eliminate another mem leak.
Fixes: 2535ba7006f22 ("src: get rid of printf")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -332,6 +332,7 @@ static int nft_run_cmd_from_buffer(struct nft_ctx *nft, struct parser_state state; LIST_HEAD(msgs); void *scanner; + FILE *fp; parser_init(nft->nf_sock, &nft->cache, &state, &msgs, nft->debug_mask, &nft->output); @@ -341,7 +342,9 @@ static int nft_run_cmd_from_buffer(struct nft_ctx *nft, if (nft_run(nft, nft->nf_sock, scanner, &state, &msgs) != 0) rc = NFT_EXIT_FAILURE; - erec_print_list(stderr, &msgs, nft->debug_mask); + fp = nft_ctx_set_output(nft, stderr); + erec_print_list(&nft->output, &msgs, nft->debug_mask); + nft_ctx_set_output(nft, fp); scanner_destroy(scanner); return rc; @@ -353,6 +356,7 @@ static int nft_run_cmd_from_filename(struct nft_ctx *nft, const char *filename) LIST_HEAD(msgs); void *scanner; int rc; + FILE *fp; rc = cache_update(nft->nf_sock, &nft->cache, CMD_INVALID, &msgs, nft->debug_mask, &nft->output); @@ -370,7 +374,9 @@ static int nft_run_cmd_from_filename(struct nft_ctx *nft, const char *filename) if (nft_run(nft, nft->nf_sock, scanner, &state, &msgs) != 0) rc = NFT_EXIT_FAILURE; err: - erec_print_list(stderr, &msgs, nft->debug_mask); + fp = nft_ctx_set_output(nft, stderr); + erec_print_list(&nft->output, &msgs, nft->debug_mask); + nft_ctx_set_output(nft, fp); scanner_destroy(scanner); return rc; |