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 --- 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;
On Saturday, December 2, 2017 8:45:59 AM CET Sven Eckelmann wrote:
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
Applied in 2ea390c.
Thank you! Simon
b.a.t.m.a.n@lists.open-mesh.org