Skip to contentSkip to conversation

ifstat: handle strdup return value

PATCH Applied Denis Kirjanov 2 participants 2 messages Mar 18, 2024 – Mar 20, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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

---
 misc/ifstat.c | 4 ++++
 1 file changed, 4 insertions(+)
misc/ifstat.c +4 -0
index 685e66c9..352e5622 100644
@@ -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));
Signature · 1 line
2.30.2
#1 lore raw
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Hello:

This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Quoted 8 lines · On Mon, 18 Mar 2024 05:15:41 -0400 you wrote:

get_nlmsg_extended is missing the check as
it's done in get_nlmsg

v2: don't set the errno value explicitly

[...]

Here is the summary with links:
- [iproute2,v2] ifstat: handle strdup return value

    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=b22a3430bd17

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html