From: Denis Kirjanov Date: Mon, 18 Mar 2024 09:15:41 +0000 (-0400) Subject: ifstat: handle strdup return value X-Git-Tag: v6.9.0~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b22a3430bd17c4f75e6f113ecfeb8ea386d6b408;p=thirdparty%2Fiproute2.git ifstat: handle strdup return value get_nlmsg_extended is missing the check as it's done in get_nlmsg v2: don't set the errno value explicitly Signed-off-by: Denis Kirjanov Signed-off-by: Stephen Hemminger --- diff --git a/misc/ifstat.c b/misc/ifstat.c index 685e66c9..352e5622 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -140,6 +140,10 @@ static int get_nlmsg_extended(struct nlmsghdr *m, void *arg) n->ifindex = ifsm->ifindex; n->name = strdup(ll_index_to_name(ifsm->ifindex)); + if (!n->name) { + free(n); + return -1; + } if (sub_type == NO_SUB_TYPE) { memcpy(&n->val, RTA_DATA(tb[filter_type]), sizeof(n->val));