From: Pauli Date: Mon, 28 Jun 2021 22:05:19 +0000 (+1000) Subject: s_time: avoid unlikely division by zero X-Git-Tag: openssl-3.0.0-beta2~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=159dacca4682a48ccc3625c64678b7eaf31681ef;p=thirdparty%2Fopenssl.git s_time: avoid unlikely division by zero Fixing coverity 966560 Division or modulo by zero (DIVIDE_BY_ZERO) Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15943) --- diff --git a/apps/s_time.c b/apps/s_time.c index 34e939d0472..1a58e19de53 100644 --- a/apps/s_time.c +++ b/apps/s_time.c @@ -394,10 +394,13 @@ int s_time_main(int argc, char **argv) printf ("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\n", nConn, totalTime, ((double)nConn / totalTime), bytes_read); - printf - ("%d connections in %ld real seconds, %ld bytes read per connection\n", - nConn, (long)time(NULL) - finishtime + maxtime, bytes_read / nConn); - + if (nConn > 0) + printf + ("%d connections in %ld real seconds, %ld bytes read per connection\n", + nConn, (long)time(NULL) - finishtime + maxtime, bytes_read / nConn); + else + printf("0 connections in %ld real seconds\n", + (long)time(NULL) - finishtime + maxtime); ret = 0; end: