]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: netlink: netlink_delinearize_table() may return NULL
authorPhil Sutter <phil@nwl.cc>
Fri, 8 Aug 2025 12:21:41 +0000 (14:21 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 17 Aug 2025 21:56:26 +0000 (23:56 +0200)
commit a69d552a005ba467d37e225032e35d01d9491241 upstream.

Catch the error condition in callers to avoid crashes.

Fixes: c156232a530b3 ("src: add comment support when adding tables")
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/monitor.c
src/netlink.c

index 8bca166bee96abb71c47557ab57bc09cdbf2ef6c..d5986d7cdfe107c21641031dac6d81fdb09c39bd 100644 (file)
@@ -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) {
index d30721cce02ebaded69b4ac4c3895b931afe0126..f6f90ac1672bec2a44bea025f01088c73c769a4e 100644 (file)
@@ -789,7 +789,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;
 }