Skip to contentSkip to conversation

batctl: Handle allocation error in vlan_get_link_parse

PATCH Applied Sven Eckelmann 2 participants 2 messages Dec 2, 2017 – Dec 4, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batctl: Handle allocation error in vlan_get_link_parse

The malloc could fail and return NULL. In this case, the processing of the current interface index has to be stopped to avoid writing to NULL (which would cause a segfault).

Fixes d29288fe0583 ("batctl: implement vlan-to-link helper functions")
---
 functions.c | 3 +++
 1 file changed, 3 insertions(+)
functions.c +3 -0
index 8bcf52d..5e4eda0 100644
@@ -812,6 +812,9 @@ static int vlan_get_link_parse(struct nl_msg *msg, void *arg)
 	idx = *(int *)nla_data(tb[IFLA_LINK]);
 	free(nl_arg->iface);
 	nl_arg->iface = malloc(IFNAMSIZ + 1);
+	if (!nl_arg->iface)
+		goto err;
+
 	if (!if_indextoname(idx, nl_arg->iface))
 		goto err;
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 6 lines · CET Sven Eckelmann

The malloc could fail and return NULL. In this case, the processing of the current interface index has to be stopped to avoid writing to NULL (which would cause a segfault).

Fixes d29288fe0583 ("batctl: implement vlan-to-link helper functions")

Applied in 2ea390c.

Thank you!
Simon