src: netlink: netlink_delinearize_table() may return NULL
Phil Sutter
reviewerPATCH 1/1 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 <[email protected]>
--- src/monitor.c | 4 ++++ src/netlink.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-)
src/monitor.c +4 -0
@@ -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) {
src/netlink.c +2 -1
@@ -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 ; }
Signature · 1 line
2.49.0
Phil Sutter
reviewerQuoted 4 lines · Phil Sutter
Catch the error condition in callers to avoid crashes.
Fixes c156232a530b3 ("src: add comment support when adding tables")Signed-off-by Phil Sutter <[email protected]>
Patch applied.