Skip to contentSkip to conversation

erec: Dump locations' expressions only if set

PATCH New Phil Sutter 1 participant 1 message Aug 30, 2022 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 erec: Dump locations' expressions only if set

Calling netlink_dump_expr() with a NULL pointer leads to segfault within libnftnl. Internal ("fake") locations such as 'netlink_location' don't have an expression assigned so expect this and skip the call. Simple reproducer (list ruleset with netlink debugging as non-root):

| $ nft -d netlink list ruleset

---
 src/erec.c | 2 ++
 1 file changed, 2 insertions(+)
src/erec.c +2 -0
index a4b93fb0d0d61..aebb8632583a1 100644
@@ -170,6 +170,8 @@ void erec_print(struct output_ctx *octx, const struct error_record *erec,
 		fprintf(f, "%s\n", erec->msg);
 		for (l = 0; l < (int)erec->num_locations; l++) {
 			loc = &erec->locations[l];
+			if (!loc->nle)
+				continue;
 			netlink_dump_expr(loc->nle, f, debug_mask);
 		}
 		return;
Signature · 1 line
2.34.1