batctl: Handle allocation error in vlan_get_link_parse
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")
Signed-off-by Sven Eckelmann <[email protected]>
--- functions.c | 3 +++ 1 file changed, 3 insertions(+)
functions.c +3 -0
@@ -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
Simon Wunderlich
AppliedQuoted 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")Signed-off-by Sven Eckelmann <[email protected]>
Applied in 2ea390c.
Thank you!
Simon