]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
segtree: fix crash when debug mode is active
authorFlorian Westphal <fw@strlen.de>
Mon, 4 Mar 2019 00:06:05 +0000 (01:06 +0100)
committerFlorian Westphal <fw@strlen.de>
Mon, 4 Mar 2019 00:15:42 +0000 (01:15 +0100)
We must set output_fp to sensible filep, else crash.

Reported-by: Václav Zindulka <vaclav.zindulka@tlapnet.cz>
Signed-off-by: Florian Westphal <fw@strlen.de>
src/segtree.c

index e5dfd413ef837675c80cd8b2f19226ee2666a9da..e3a2f48c22387c86f80b5a12606e9892c2bad712 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <inttypes.h>
 #include <arpa/inet.h>
 
@@ -67,8 +68,6 @@ struct elementary_interval {
        struct expr                     *expr;
 };
 
-static struct output_ctx debug_octx = {};
-
 static void seg_tree_init(struct seg_tree *tree, const struct set *set,
                          struct expr *init, unsigned int debug_mask)
 {
@@ -570,6 +569,7 @@ int set_to_intervals(struct list_head *errs, struct set *set,
                     bool merge)
 {
        struct elementary_interval *ei, *next;
+       struct output_ctx debug_octx;
        struct seg_tree tree;
        LIST_HEAD(list);
 
@@ -590,6 +590,9 @@ int set_to_intervals(struct list_head *errs, struct set *set,
        }
 
        if (segtree_debug(tree.debug_mask)) {
+               memset(&debug_octx, 0, sizeof(debug_octx));
+               debug_octx.output_fp = stderr;
+               debug_octx.error_fp = stderr;
                expr_print(init, &debug_octx);
                pr_gmp_debug("\n");
        }