]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
rttable: Fix invalid range checking when table id is converted to u32
authorDavid Ahern <dsa@cumulusnetworks.com>
Tue, 10 Jan 2017 23:33:55 +0000 (15:33 -0800)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 13 Jan 2017 01:34:22 +0000 (17:34 -0800)
Frank reported that table ids for very large numbers are not properly
detected:
$ ip li add foobar type vrf table 98765432100123456789

command succeeds and resulting table id is actually:

21: foobar: <NOARP,MASTER> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether da:ea:d4:77:38:2a brd ff:ff:ff:ff:ff:ff promiscuity 0
    vrf table 4294967295 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

Make the temp variable 'i' unsigned long and let the typecast to u32
happen on assignment to id.

Reported-by: Frank Kellermann <frank.kellermann@atos.net>
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
lib/rt_names.c

index 7553288eeb1815e42295b1aadffd4eb9f812640b..3a16d5cf9bb573eb3b207c2917c84500c916f5fd 100644 (file)
@@ -431,7 +431,7 @@ int rtnl_rttable_a2n(__u32 *id, const char *arg)
        static unsigned long res;
        struct rtnl_hash_entry *entry;
        char *end;
-       __u32 i;
+       unsigned long i;
 
        if (cache && strcmp(cache, arg) == 0) {
                *id = res;