Message ID | 20200416140814.171242-1-odin@ugedal.com |
---|---|
State | New |
Headers | show |
Series | [1/3] q_cake: Make fwmark uint instead of int | expand |
Odin Ugedal <odin@ugedal.com> writes: > 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> Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
diff --git a/tc/tc_util.c b/tc/tc_util.c index 5f13d729..68938fb0 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; }
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> --- tc/tc_util.c | 5 +++++ 1 file changed, 5 insertions(+)