From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH] batctl: Handle allocation error in vlan_get_link_parse
Date: Sat, 2 Dec 2017 08:45:59 +0100 [thread overview]
Message-ID: <20171202074559.3582-1-sven@narfation.org> (raw)
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
next reply other threads:[~2017-12-02 7:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-02 7:45 Sven Eckelmann [this message]
2017-12-04 11:59 ` [B.A.T.M.A.N.] [PATCH] batctl: Handle allocation error in vlan_get_link_parse Simon Wunderlich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171202074559.3582-1-sven@narfation.org \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox