Date: Wed, 10 Oct 2012 11:11:02 GMT From: Erik Cederstrand <erik@cederstrand.dk> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/172569: Fix div-by-zero in openssl Message-ID: <201210101111.q9ABB21Q021402@red.freebsd.org> Resent-Message-ID: <201210101120.q9ABK1Tv072970@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 172569 >Category: misc >Synopsis: Fix div-by-zero in openssl >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Oct 10 11:20:01 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Erik Cederstrand >Release: CURRENT >Organization: >Environment: >Description: Fix an (extremely unlikely) divide-by-zero in openssl, found by Clang Analyzer: http://scan.freebsd.your.org/freebsd-head/LATEST/secure/report-jo4Joj.html#EndPath This can only happen if the process is stalled for more than SECONDS seconds (currently 30) between lines 397 and 401. Fix an identical case while there. >How-To-Repeat: >Fix: See patch Patch attached with submission follows: Index: head/crypto/openssl/apps/s_time.c =================================================================== --- head/crypto/openssl/apps/s_time.c (revision 241370) +++ head/crypto/openssl/apps/s_time.c (working copy) @@ -449,6 +449,10 @@ } totalTime += tm_Time_F(STOP); /* Add the time for this iteration */ + if (nConn == 0) { + fprintf( stderr, "Unable to get any connections\n" ); + goto end; + } i=(int)((long)time(NULL)-finishtime+maxTime); 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); @@ -540,6 +544,10 @@ totalTime += tm_Time_F(STOP); /* Add the time for this iteration*/ + if (nConn == 0) { + fprintf( stderr, "Unable to get any connections\n" ); + goto end; + } 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); >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210101111.q9ABB21Q021402>