]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
s_time: avoid unlikely division by zero
authorPauli <pauli@openssl.org>
Mon, 28 Jun 2021 22:05:19 +0000 (08:05 +1000)
committerPauli <pauli@openssl.org>
Wed, 30 Jun 2021 03:55:09 +0000 (13:55 +1000)
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)

apps/s_time.c

index 34e939d0472c9d1c9f69c806744d05d7530f303c..1a58e19de53fe7eeaa3c469df6aa54534e32ca35 100644 (file)
@@ -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: