From owner-freebsd-bugs@FreeBSD.ORG Wed Oct 10 11:20:01 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B226C774 for ; Wed, 10 Oct 2012 11:20:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [8.8.178.135]) by mx1.freebsd.org (Postfix) with ESMTP id 88DB48FC16 for ; Wed, 10 Oct 2012 11:20:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q9ABK1wc072971 for ; Wed, 10 Oct 2012 11:20:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q9ABK1Tv072970; Wed, 10 Oct 2012 11:20:01 GMT (envelope-from gnats) Resent-Date: Wed, 10 Oct 2012 11:20:01 GMT Resent-Message-Id: <201210101120.q9ABK1Tv072970@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Erik Cederstrand Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 69741693 for ; Wed, 10 Oct 2012 11:11:02 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 523FE8FC12 for ; Wed, 10 Oct 2012 11:11:02 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q9ABB2gk021403 for ; Wed, 10 Oct 2012 11:11:02 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id q9ABB21Q021402; Wed, 10 Oct 2012 11:11:02 GMT (envelope-from nobody) Message-Id: <201210101111.q9ABB21Q021402@red.freebsd.org> Date: Wed, 10 Oct 2012 11:11:02 GMT From: Erik Cederstrand To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: misc/172569: Fix div-by-zero in openssl X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Oct 2012 11:20:01 -0000 >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: