From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: shemminger@vyatta.com
Cc: netdev@vger.kernel.org, Nicolas Dichtel <nicolas.dichtel@6wind.com>
Subject: [PATCH iproute2] libnetlink: don't confuse variables in rtnl_talk()
Date: Thu, 3 Dec 2015 17:13:48 +0100 [thread overview]
Message-ID: <1449159228-4233-1-git-send-email-nicolas.dichtel@6wind.com> (raw)
There is two variables named 'len' in rtnl_talk. In fact, commit
c079e121a73a didn't work. For example, it was possible to trigger
a seg fault with this command:
$ ip link set gre2 type ip6gre hoplimit 32
Let's rename the argument len to maxlen.
Fixes: c079e121a73a ("libnetlink: add size argument to rtnl_talk")
Reported-by: Thomas Faivre <thomas.faivre@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
lib/libnetlink.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 922ec2d9f872..165821447b2d 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -332,7 +332,7 @@ int rtnl_dump_filter_nc(struct rtnl_handle *rth,
}
int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
- struct nlmsghdr *answer, size_t len)
+ struct nlmsghdr *answer, size_t maxlen)
{
int status;
unsigned seq;
@@ -415,7 +415,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
} else if (!err->error) {
if (answer)
memcpy(answer, h,
- MIN(len, h->nlmsg_len));
+ MIN(maxlen, h->nlmsg_len));
return 0;
}
@@ -427,7 +427,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
if (answer) {
memcpy(answer, h,
- MIN(len, h->nlmsg_len));
+ MIN(maxlen, h->nlmsg_len));
return 0;
}
--
2.4.2
next reply other threads:[~2015-12-03 16:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-03 16:13 Nicolas Dichtel [this message]
2015-12-10 16:49 ` [PATCH iproute2] libnetlink: don't confuse variables in rtnl_talk() Stephen Hemminger
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=1449159228-4233-1-git-send-email-nicolas.dichtel@6wind.com \
--to=nicolas.dichtel@6wind.com \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/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;
as well as URLs for NNTP newsgroup(s).