* [B.A.T.M.A.N.] [PATCH] batctl: Handle allocation error in vlan_get_link_parse
@ 2017-12-02 7:45 Sven Eckelmann
2017-12-04 11:59 ` Simon Wunderlich
0 siblings, 1 reply; 2+ messages in thread
From: Sven Eckelmann @ 2017-12-02 7:45 UTC (permalink / raw)
To: b.a.t.m.a.n
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;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batctl: Handle allocation error in vlan_get_link_parse
2017-12-02 7:45 [B.A.T.M.A.N.] [PATCH] batctl: Handle allocation error in vlan_get_link_parse Sven Eckelmann
@ 2017-12-04 11:59 ` Simon Wunderlich
0 siblings, 0 replies; 2+ messages in thread
From: Simon Wunderlich @ 2017-12-04 11:59 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 421 bytes --]
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
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-12-04 11:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-02 7:45 [B.A.T.M.A.N.] [PATCH] batctl: Handle allocation error in vlan_get_link_parse Sven Eckelmann
2017-12-04 11:59 ` Simon Wunderlich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).