From: Phil Sutter Date: Fri, 8 Aug 2025 12:21:41 +0000 (+0200) Subject: src: netlink: netlink_delinearize_table() may return NULL X-Git-Tag: v1.1.5~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a69d552a005ba467d37e225032e35d01d9491241;p=thirdparty%2Fnftables.git src: netlink: netlink_delinearize_table() may return NULL Catch the error condition in callers to avoid crashes. Fixes: c156232a530b3 ("src: add comment support when adding tables") Signed-off-by: Phil Sutter --- diff --git a/src/monitor.c b/src/monitor.c index e0f97b4a..da1ad880 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -237,6 +237,10 @@ static int netlink_events_table_cb(const struct nlmsghdr *nlh, int type, nlt = netlink_table_alloc(nlh); t = netlink_delinearize_table(monh->ctx, nlt); + if (!t) { + nftnl_table_free(nlt); + return MNL_CB_ERROR; + } cmd = netlink_msg2cmd(type, nlh->nlmsg_flags); switch (monh->format) { diff --git a/src/netlink.c b/src/netlink.c index f2f4c5ea..94cbcbfc 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -841,7 +841,8 @@ static int list_table_cb(struct nftnl_table *nlt, void *arg) struct table *table; table = netlink_delinearize_table(ctx, nlt); - list_add_tail(&table->list, &ctx->list); + if (table) + list_add_tail(&table->list, &ctx->list); return 0; }