Repository : ssh://git@open-mesh.org/batctl
On branch : master
commit 2ea390ce9bdda39d3c15bd9470009f56f42d5ed9 Author: Sven Eckelmann sven@narfation.org Date: Sat Dec 2 08:45:59 2017 +0100
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 sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
2ea390ce9bdda39d3c15bd9470009f56f42d5ed9 functions.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/functions.c b/functions.c index 8bcf52d..5e4eda0 100644 --- a/functions.c +++ b/functions.c @@ -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;