]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
intervals: Fix for inconsistent union field use
authorPhil Sutter <phil@nwl.cc>
Tue, 26 May 2026 13:49:58 +0000 (15:49 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 17 Jun 2026 16:03:07 +0000 (18:03 +0200)
Reported by a static code analyzer: key->value belongs to a different
struct in the embedded anonymous union than key->range.* which is
accessed elsewhere in that function.

It is correct in that the function asserts key->etype to be
EXPR_RANGE_VALUE, so key->value is not necessarily valid (it just
happens to match key->range.low's offset.

Fixes: 91dc281a82ea6 ("src: rework singleton interval transformation to reduce memory consumption")
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/intervals.c

index c9e278b2a895adbb1de6022bb5583f80a38659dd..d6af7cbc144ecd95aabe3ed3212dc45ac1046c62 100644 (file)
@@ -832,7 +832,8 @@ int setelem_to_interval(const struct set *set, struct expr *elem,
 
        if (adjacent)
                return 0;
-       else if (!mpz_cmp_ui(key->value, 0) && elem->key->flags & EXPR_F_INTERVAL_END) {
+       else if (!mpz_cmp_ui(key->range.low, 0) &&
+                elem->key->flags & EXPR_F_INTERVAL_END) {
                low->key->flags |= EXPR_F_INTERVAL_END;
                return 0;
        } else if (mpz_scan0(key->range.high, 0) == set->key->len) {