e772cae854a280877ab87f21d64bc5ac5603a0fb
[feed/routing.git] / batctl / patches / 0013-batctl-Handle-allocation-error-in-vlan_get_link_pars.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Sat, 2 Dec 2017 08:45:59 +0100
3 Subject: [PATCH] batctl: Handle allocation error in vlan_get_link_parse
4
5 The malloc could fail and return NULL. In this case, the processing of the
6 current interface index has to be stopped to avoid writing to NULL (which
7 would cause a segfault).
8
9 Fixes: d29288fe0583 ("batctl: implement vlan-to-link helper functions")
10 Signed-off-by: Sven Eckelmann <sven@narfation.org>
11 Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
12
13 Origin: upstream, https://git.open-mesh.org/batctl.git/commit/2ea390ce9bdda39d3c15bd9470009f56f42d5ed9
14 ---
15 functions.c | 3 +++
16 1 file changed, 3 insertions(+)
17
18 diff --git a/functions.c b/functions.c
19 index 1c96e6241d01b83a136ff135bee8dd780629f7aa..f91f26f4045766474d5dc109d76e20afd91a7791 100644
20 --- a/functions.c
21 +++ b/functions.c
22 @@ -812,6 +812,9 @@ static int vlan_get_link_parse(struct nl_msg *msg, void *arg)
23 idx = *(int *)nla_data(tb[IFLA_LINK]);
24 free(nl_arg->iface);
25 nl_arg->iface = malloc(IFNAMSIZ + 1);
26 + if (!nl_arg->iface)
27 + goto err;
28 +
29 if (!if_indextoname(idx, nl_arg->iface))
30 goto err;
31