|
|
1d03cd |
From 70732ebb3cd1b847e72dce5ae8fe3c69580bd778 Mon Sep 17 00:00:00 2001
|
|
|
1d03cd |
From: Phil Sutter <psutter@redhat.com>
|
|
|
1d03cd |
Date: Thu, 9 Feb 2023 10:25:59 +0100
|
|
|
1d03cd |
Subject: [PATCH] intervals: fix crash when trying to remove element in empty
|
|
|
1d03cd |
set
|
|
|
1d03cd |
|
|
|
1d03cd |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2115627
|
|
|
1d03cd |
Upstream Status: nftables commit 5357cb7b5cb93
|
|
|
1d03cd |
|
|
|
1d03cd |
commit 5357cb7b5cb93fc9b20d4d95b093d6b9f86b7727
|
|
|
1d03cd |
Author: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
1d03cd |
Date: Thu Jun 23 14:20:17 2022 +0200
|
|
|
1d03cd |
|
|
|
1d03cd |
intervals: fix crash when trying to remove element in empty set
|
|
|
1d03cd |
|
|
|
1d03cd |
The set deletion routine expects an initialized set, otherwise it crashes.
|
|
|
1d03cd |
|
|
|
1d03cd |
Fixes: 3e8d934e4f72 ("intervals: support to partial deletion with automerge")
|
|
|
1d03cd |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
1d03cd |
|
|
|
1d03cd |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
1d03cd |
---
|
|
|
1d03cd |
src/intervals.c | 6 +++++-
|
|
|
1d03cd |
tests/shell/testcases/sets/errors_0 | 14 ++++++++++++++
|
|
|
1d03cd |
2 files changed, 19 insertions(+), 1 deletion(-)
|
|
|
1d03cd |
create mode 100755 tests/shell/testcases/sets/errors_0
|
|
|
1d03cd |
|
|
|
1d03cd |
diff --git a/src/intervals.c b/src/intervals.c
|
|
|
1d03cd |
index dcc06d1..c21b3ee 100644
|
|
|
1d03cd |
--- a/src/intervals.c
|
|
|
1d03cd |
+++ b/src/intervals.c
|
|
|
1d03cd |
@@ -475,7 +475,11 @@ int set_delete(struct list_head *msgs, struct cmd *cmd, struct set *set,
|
|
|
1d03cd |
if (set->automerge)
|
|
|
1d03cd |
automerge_delete(msgs, set, init, debug_mask);
|
|
|
1d03cd |
|
|
|
1d03cd |
- set_to_range(existing_set->init);
|
|
|
1d03cd |
+ if (existing_set->init) {
|
|
|
1d03cd |
+ set_to_range(existing_set->init);
|
|
|
1d03cd |
+ } else {
|
|
|
1d03cd |
+ existing_set->init = set_expr_alloc(&internal_location, set);
|
|
|
1d03cd |
+ }
|
|
|
1d03cd |
|
|
|
1d03cd |
list_splice_init(&init->expressions, &del_list);
|
|
|
1d03cd |
|
|
|
1d03cd |
diff --git a/tests/shell/testcases/sets/errors_0 b/tests/shell/testcases/sets/errors_0
|
|
|
1d03cd |
new file mode 100755
|
|
|
1d03cd |
index 0000000..2960b69
|
|
|
1d03cd |
--- /dev/null
|
|
|
1d03cd |
+++ b/tests/shell/testcases/sets/errors_0
|
|
|
1d03cd |
@@ -0,0 +1,14 @@
|
|
|
1d03cd |
+#!/bin/bash
|
|
|
1d03cd |
+
|
|
|
1d03cd |
+set -e
|
|
|
1d03cd |
+
|
|
|
1d03cd |
+RULESET="table ip x {
|
|
|
1d03cd |
+ set y {
|
|
|
1d03cd |
+ type ipv4_addr
|
|
|
1d03cd |
+ flags interval
|
|
|
1d03cd |
+ }
|
|
|
1d03cd |
+}
|
|
|
1d03cd |
+
|
|
|
1d03cd |
+delete element ip x y { 2.3.4.5 }"
|
|
|
1d03cd |
+
|
|
|
1d03cd |
+$NFT -f - <<< $RULESET || exit 0
|
|
|
1d03cd |
--
|
|
|
1d03cd |
2.39.1
|
|
|
1d03cd |
|