]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
tc_util: detect overflow in get_size
authorOdin Ugedal <odin@ugedal.com>
Thu, 16 Apr 2020 14:08:14 +0000 (16:08 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 20 Apr 2020 16:31:01 +0000 (09:31 -0700)
This detects overflow during parsing of value using get_size:

eg. running:

$ tc qdisc add dev lo root cake memlimit 11gb

currently gives a memlimit of "3072Mb", while with this patch it errors
with 'illegal value for "memlimit": "11gb"', since memlinit is an
unsigned integer.

Signed-off-by: Odin Ugedal <odin@ugedal.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/tc_util.c

index 5f13d729bf52ee7d88916859de58d8061616cbf0..68938fb0ccddc8c8b9020b358501e7fd58a9b288 100644 (file)
@@ -385,6 +385,11 @@ int get_size(unsigned int *size, const char *str)
        }
 
        *size = sz;
+
+       /* detect if an overflow happened */
+       if (*size != floor(sz))
+               return -1;
+
        return 0;
 }