parse_percent() takes a bare "%" as 0 and accepts NaN, which netem then sends as 0. Require digits and refuse NaN. Fixes: 927e3cfb52b5 ("tc: B.W limits can now be specified in %.") Signed-off-by: Andrii Tereshchenko --- netem loss random nan: was loss 0, now Illegal "loss percent". tc/tc_util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tc/tc_util.c b/tc/tc_util.c index 5f03f950..27e64d0e 100644 --- a/tc/tc_util.c +++ b/tc/tc_util.c @@ -175,6 +175,8 @@ int parse_percent(double *val, const char *str) char *p; *val = strtod(str, &p) / 100.; + if (p == str || isnan(*val)) + return -1; if (*val > 1.0 || *val < 0.0) return 1; if (*p && strcmp(p, "%")) base-commit: 06b62d179bbb5b62cba965dcda48a613dbc59416 -- 2.53.0