From: Matt Caswell Date: Thu, 12 Mar 2015 16:42:55 +0000 (+0000) Subject: Fix seg fault in s_time X-Git-Tag: OpenSSL_1_0_2a~21 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6c4ce00753c5763cf836f6fec9ec07ed7c2e6e03;p=oweals%2Fopenssl.git 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 (cherry picked from commit dfef52f6f277327e118fdd0fe34486852c2789b6) --- 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: