Commit ed108cfc authored by Nicolas Dichtel's avatar Nicolas Dichtel Committed by Stephen Hemminger

libnetlink: don't confuse variables in rtnl_talk()

There is two variables named 'len' in rtnl_talk. In fact, commit
c079e121 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: c079e121 ("libnetlink: add size argument to rtnl_talk")
Reported-by: default avatarThomas Faivre <thomas.faivre@6wind.com>
Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
parent 0f754332
...@@ -332,7 +332,7 @@ int rtnl_dump_filter_nc(struct rtnl_handle *rth, ...@@ -332,7 +332,7 @@ int rtnl_dump_filter_nc(struct rtnl_handle *rth,
} }
int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
struct nlmsghdr *answer, size_t len) struct nlmsghdr *answer, size_t maxlen)
{ {
int status; int status;
unsigned seq; unsigned seq;
...@@ -415,7 +415,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, ...@@ -415,7 +415,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
} else if (!err->error) { } else if (!err->error) {
if (answer) if (answer)
memcpy(answer, h, memcpy(answer, h,
MIN(len, h->nlmsg_len)); MIN(maxlen, h->nlmsg_len));
return 0; return 0;
} }
...@@ -427,7 +427,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, ...@@ -427,7 +427,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
if (answer) { if (answer) {
memcpy(answer, h, memcpy(answer, h,
MIN(len, h->nlmsg_len)); MIN(maxlen, h->nlmsg_len));
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment