summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2015-03-12 16:42:55 +0000
committerMatt Caswell <matt@openssl.org>2015-03-17 13:49:32 +0000
commit6a43243d1d54a8bc4056eab76237e7d474edaafc (patch)
treec1046fb51a6427c69ba1c54ab372b388fd1eba30
parentf08731cd82566d14275b7749ca553bdd7f6267f3 (diff)
downloadopenssl-new-6a43243d1d54a8bc4056eab76237e7d474edaafc.tar.gz
Fix seg fault in s_time
Passing a negative value for the "-time" option to s_time results in a seg fault. This commit fixes it so that time has to be greater than 0. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit dfef52f6f277327e118fdd0fe34486852c2789b6)
-rw-r--r--apps/s_time.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/apps/s_time.c b/apps/s_time.c
index 5846f3ae17..a40997a22e 100644
--- a/apps/s_time.c
+++ b/apps/s_time.c
@@ -302,6 +302,10 @@ static int parseArgs(int argc, char **argv)
if (--argc < 1)
goto bad;
maxTime = atoi(*(++argv));
+ if(maxTime <= 0) {
+ BIO_printf(bio_err, "time must be > 0\n");
+ badop = 1;
+ }
} else {
BIO_printf(bio_err, "unknown option %s\n", *argv);
badop = 1;
@@ -550,7 +554,8 @@ int MAIN(int argc, char **argv)
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);
+ nConn, (long)time(NULL) - finishtime + maxTime,
+ bytes_read / (nConn?nConn:1));
ret = 0;
end: