]> granicus.if.org Git - apache/commitdiff
* support/ab.c: Fix crash caused by integer overflow when printing stats with
authorJan Kaluža <jkaluza@apache.org>
Thu, 14 Aug 2014 12:15:31 +0000 (12:15 +0000)
committerJan Kaluža <jkaluza@apache.org>
Thu, 14 Aug 2014 12:15:31 +0000 (12:15 +0000)
lot of requests (for example -n 500000000).

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1617913 13f79535-47bb-0310-9956-ffa450edef68

support/ab.c

index f9888e15922df5988b2271ce7102211e715ac0ab..7f0777b23a10353b239a9b06feba78cf0b12dabc 100644 (file)
@@ -1029,7 +1029,7 @@ static void output_results(int sig)
                            ap_round_ms(stats[done - 1].time));
                 else
                     printf("  %d%%  %5" APR_TIME_T_FMT "\n", percs[i],
-                           ap_round_ms(stats[(int) (done * percs[i] / 100)].time));
+                           ap_round_ms(stats[(unsigned long)done * percs[i] / 100].time));
             }
         }
         if (csvperc) {
@@ -1046,7 +1046,7 @@ static void output_results(int sig)
                 else if (i == 100)
                     t = ap_double_ms(stats[done - 1].time);
                 else
-                    t = ap_double_ms(stats[(int) (0.5 + done * i / 100.0)].time);
+                    t = ap_double_ms(stats[(unsigned long) (0.5 + (double)done * i / 100.0)].time);
                 fprintf(out, "%d,%.3f\n", i, t);
             }
             fclose(out);