diff mbox

[1/1] iproute2: wrong error when label is more than 15 chars

Message ID 1395830388-13874-1-git-send-email-snagarka@redhat.com
State Rejected, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Swapnil Nagarkar March 26, 2014, 10:39 a.m. UTC
The string for "label" option in "ip" command does not take more than 15 chanracters.
Gives error "RTNETLINK answers: Numerical result out of range".
$ ip addr add 10.65.X.X/23 dev em1:1 label em1:123456789012
RTNETLINK answers: Numerical result out of range
$ ip addr add 10.65.X.X/23 dev em1:1 label em1:12345678901

Adding check for maximum length of interface name and proper error
message.

After patch output:-
$ ./ip addr replace 192.168.50.4 dev em1:123 label em1:123456789012
Error: argument "em1:123456789012" is wrong: invalid label value.

Signed-off-by: Swapnil Nagarkar <snagarka@redhat.com>
---
 ip/ipaddress.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Stephen Hemminger April 1, 2014, 3:48 a.m. UTC | #1
On Wed, 26 Mar 2014 16:09:48 +0530
Swapnil Nagarkar <snagarka@redhat.com> wrote:

> The string for "label" option in "ip" command does not take more than 15 chanracters.
> Gives error "RTNETLINK answers: Numerical result out of range".
> $ ip addr add 10.65.X.X/23 dev em1:1 label em1:123456789012
> RTNETLINK answers: Numerical result out of range
> $ ip addr add 10.65.X.X/23 dev em1:1 label em1:12345678901
> 
> Adding check for maximum length of interface name and proper error
> message.
> 
> After patch output:-
> $ ./ip addr replace 192.168.50.4 dev em1:123 label em1:123456789012
> Error: argument "em1:123456789012" is wrong: invalid label value.
> 
> Signed-off-by: Swapnil Nagarkar <snagarka@redhat.com>

I am not sure I like ip route commands trying to "fix up" kernel errors
like this. There are lots of possible error cases, and this one is so much
a corner case it doesn't seem right to step in and do something special.

The error number comes from the netlink attribute validation policy
and although the glibc error string is less than useful, the concept of
name too long does fit in the general meaning of ERANGE.

Unless there is a compelling outcry, I am going to reject this.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 14d1720..b74517d 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1358,6 +1358,8 @@  static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
 		} else if (strcmp(*argv, "label") == 0) {
 			NEXT_ARG();
 			l = *argv;
+			if (strlen(l) >= IFNAMSIZ)
+				invarg("invalid label value.", *argv);
 			addattr_l(&req.n, sizeof(req), IFA_LABEL, l, strlen(l)+1);
 		} else if (matches(*argv, "valid_lft") == 0) {
 			if (valid_lftp)