From 106e14ce87c5b1984727aabf9a48f7284bff21c1 Mon Sep 17 00:00:00 2001 From: Felix Abecassis Date: Thu, 13 May 2021 17:02:40 -0700 Subject: [PATCH] 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 --- stat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.25.1