From: Felix Abecassis Date: Fri, 14 May 2021 00:02:40 +0000 (-0700) Subject: stat: fix integer overflow in convert_agg_kbytes_percent X-Git-Tag: fio-3.27~3^2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=106e14ce87c5b1984727aabf9a48f7284bff21c1;p=fio.git stat: fix integer overflow in convert_agg_kbytes_percent Assuming that "int" is 32-bit, for high bandwidth values (> 21.5 GB/s) the expression "mean * 100" will cause an integer overflow before the conversion to "double" happens. Signed-off-by: Felix Abecassis --- diff --git a/stat.c b/stat.c index b7222f46..a8a96c85 100644 --- a/stat.c +++ b/stat.c @@ -462,7 +462,7 @@ static double convert_agg_kbytes_percent(struct group_run_stats *rs, int ddir, i { double p_of_agg = 100.0; if (rs && rs->agg[ddir] > 1024) { - p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024.0); + p_of_agg = mean * 100.0 / (double) (rs->agg[ddir] / 1024.0); if (p_of_agg > 100.0) p_of_agg = 100.0;