From owner-svn-src-head@FreeBSD.ORG Wed Jan 2 20:58:47 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0DBFEB90; Wed, 2 Jan 2013 20:58:47 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EEB912CC; Wed, 2 Jan 2013 20:58:46 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r02KwkF8061954; Wed, 2 Jan 2013 20:58:46 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r02Kwk9b061953; Wed, 2 Jan 2013 20:58:46 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201301022058.r02Kwk9b061953@svn.freebsd.org> From: Xin LI Date: Wed, 2 Jan 2013 20:58:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244974 - head/crypto/openssl/crypto/bn X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jan 2013 20:58:47 -0000 Author: delphij Date: Wed Jan 2 20:58:46 2013 New Revision: 244974 URL: http://svnweb.freebsd.org/changeset/base/244974 Log: MFV r244973: Integrate OpenSSL changeset 22950 (appro): bn_word.c: fix overflow bug in BN_add_word. MFC after: 2 weeks Modified: head/crypto/openssl/crypto/bn/bn_word.c Directory Properties: head/crypto/openssl/ (props changed) Modified: head/crypto/openssl/crypto/bn/bn_word.c ============================================================================== --- head/crypto/openssl/crypto/bn/bn_word.c Wed Jan 2 20:56:53 2013 (r244973) +++ head/crypto/openssl/crypto/bn/bn_word.c Wed Jan 2 20:58:46 2013 (r244974) @@ -144,26 +144,17 @@ int BN_add_word(BIGNUM *a, BN_ULONG w) a->neg=!(a->neg); return(i); } - /* Only expand (and risk failing) if it's possibly necessary */ - if (((BN_ULONG)(a->d[a->top - 1] + 1) == 0) && - (bn_wexpand(a,a->top+1) == NULL)) - return(0); - i=0; - for (;;) + for (i=0;w!=0 && itop;i++) { - if (i >= a->top) - l=w; - else - l=(a->d[i]+w)&BN_MASK2; - a->d[i]=l; - if (w > l) - w=1; - else - break; - i++; + a->d[i] = l = (a->d[i]+w)&BN_MASK2; + w = (w>l)?1:0; } - if (i >= a->top) + if (w && i==a->top) + { + if (bn_wexpand(a,a->top+1) == NULL) return 0; a->top++; + a->d[i]=w; + } bn_check_top(a); return(1); }