All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] libnetlink: don't confuse variables in rtnl_talk()
@ 2015-12-03 16:13 Nicolas Dichtel
  2015-12-10 16:49 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Dichtel @ 2015-12-03 16:13 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, Nicolas Dichtel

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2] libnetlink: don't confuse variables in rtnl_talk()
  2015-12-03 16:13 [PATCH iproute2] libnetlink: don't confuse variables in rtnl_talk() Nicolas Dichtel
@ 2015-12-10 16:49 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2015-12-10 16:49 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: shemminger, netdev

On Thu,  3 Dec 2015 17:13:48 +0100
Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:

> 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>

Applied, thanks, Not sure why compiler isn't catching this.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-10 16:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-03 16:13 [PATCH iproute2] libnetlink: don't confuse variables in rtnl_talk() Nicolas Dichtel
2015-12-10 16:49 ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.