Skip to contentSkip to conversation

intervals: Fix for inconsistent union field use

PATCH In review Phil Sutter 1 participant 2 messages Jun 3 – Jun 17 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 intervals: Fix for inconsistent union field use

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")
---
 src/intervals.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/intervals.c +2 -1
index c9e278b2a895a..d6af7cbc144ec 100644
@@ -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) {
Signature · 1 line
2.54.0
author reviewer
#1 lore raw
Quoted 10 lines · Phil Sutter

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")

Patch applied.