]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
segtree: keep element comments in set intervals
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 8 Nov 2016 23:19:45 +0000 (00:19 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 9 Nov 2016 19:03:51 +0000 (20:03 +0100)
The conversion from the set element range representation to element
intervals doesn't keep the comment information around.

Fixes: https://bugzilla.netfilter.org/show_bug.cgi?id=1090
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Tested-by: Arturo Borrero Gonzalez <arturo@debian.org>
src/segtree.c

index fa11967adbd25041645a8445977d6df767ff5413..32e071f6b5e8c5ca90913dbe1206a7402310470f 100644 (file)
@@ -522,9 +522,13 @@ static void set_insert_interval(struct expr *set, struct seg_tree *tree,
        mpz_set(expr->value, ei->left);
        expr = set_elem_expr_alloc(&internal_location, expr);
 
-       if (ei->expr != NULL && ei->expr->ops->type == EXPR_MAPPING)
-               expr = mapping_expr_alloc(&ei->expr->location, expr,
-                                         expr_get(ei->expr->right));
+       if (ei->expr != NULL) {
+               if (ei->expr->comment)
+                       expr->comment = xstrdup(ei->expr->comment);
+               if (ei->expr->ops->type == EXPR_MAPPING)
+                       expr = mapping_expr_alloc(&ei->expr->location, expr,
+                                                 expr_get(ei->expr->right));
+       }
 
        if (ei->flags & EI_F_INTERVAL_END)
                expr->flags |= EXPR_F_INTERVAL_END;