]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink: Avoid memleak in error path of netlink_delinearize_table()
authorPhil Sutter <phil@nwl.cc>
Fri, 11 Jun 2021 16:33:44 +0000 (18:33 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 14 Jun 2021 11:31:07 +0000 (13:31 +0200)
If parsing udata fails, 'table' has to be freed before returning to
caller.

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

index 1bbdf98bd2ee25f063047b3a33326c65180849ff..be98bfb7f5c1240c1d2579f63e047c39d4c2415e 100644 (file)
@@ -647,6 +647,7 @@ struct table *netlink_delinearize_table(struct netlink_ctx *ctx,
                udata = nftnl_table_get_data(nlt, NFTNL_TABLE_USERDATA, &ulen);
                if (nftnl_udata_parse(udata, ulen, table_parse_udata_cb, ud) < 0) {
                        netlink_io_error(ctx, NULL, "Cannot parse userdata");
+                       table_free(table);
                        return NULL;
                }
                if (ud[NFTNL_UDATA_TABLE_COMMENT])