diff options
author | Pauli <pauli@openssl.org> | 2021-06-29 08:05:19 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-30 13:55:09 +1000 |
commit | 159dacca4682a48ccc3625c64678b7eaf31681ef (patch) | |
tree | bca2adf2d9e04510ad048708fa9998ca71c16cbb /apps/s_time.c | |
parent | 196feb18de28cc5e6b59483ab61453dbca8d5c4b (diff) |
s_time: avoid unlikely division by zero
Fixing coverity 966560 Division or modulo by zero (DIVIDE_BY_ZERO)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15943)
Diffstat (limited to 'apps/s_time.c')
-rw-r--r-- | apps/s_time.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/apps/s_time.c b/apps/s_time.c index 34e939d047..1a58e19de5 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: |