aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOdin Ugedal <odin@ugedal.com>2020-04-16 16:08:14 +0200
committerStephen Hemminger <stephen@networkplumber.org>2020-04-20 09:31:01 -0700
commite07c57e94e27d2f15bfb9de4db7ca3ab9d9368ed (patch)
tree399103e9d03d1ef3fc3216e8ed490e4edbf9959c
parentfe821d64e60cee2abc4347b3f67e8a3d698777a0 (diff)
downloadiproute2-e07c57e94e27d2f15bfb9de4db7ca3ab9d9368ed.tar.gz
tc_util: detect overflow in get_size
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>
-rw-r--r--tc/tc_util.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 5f13d729b..68938fb0c 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -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;
}