Check that the rate fits in 64 bits before converting it to an integer. Without the check # tc qdisc add dev lo root tbf rate nan burst 10k limit 10k is accepted and installs "rate 0bit". ULLONG_MAX rounds to 2^64 as a double, so reject equality as well. The explicit cast avoids clang's conversion warning. Fixes: 8334bb325d51 ("htb: support 64bit rates") Signed-off-by: Dave Seddon --- lib/utils_math.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/utils_math.c b/lib/utils_math.c index 4b0ac266..d082a391 100644 --- a/lib/utils_math.c +++ b/lib/utils_math.c @@ -97,6 +97,9 @@ int get_rate64(__u64 *rate, const char *str) return -1; /* unknown suffix */ bps /= 8; /* -> bytes per second */ + if (isnan(bps) || bps >= (double)ULLONG_MAX) + return -1; + *rate = bps; return 0; } -- 2.56.0