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

Fixes: 293c9b114faef ("src: add comment support for objects")
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/netlink.c

index be98bfb7f5c1240c1d2579f63e047c39d4c2415e..f2c1a4a15dee8f2e33697d530170e8306ad0171b 100644 (file)
@@ -1450,6 +1450,7 @@ struct obj *netlink_delinearize_obj(struct netlink_ctx *ctx,
                udata = nftnl_obj_get_data(nlo, NFTNL_OBJ_USERDATA, &ulen);
                if (nftnl_udata_parse(udata, ulen, obj_parse_udata_cb, ud) < 0) {
                        netlink_io_error(ctx, NULL, "Cannot parse userdata");
+                       obj_free(obj);
                        return NULL;
                }
                if (ud[NFTNL_UDATA_OBJ_COMMENT])