From owner-svn-ports-head@freebsd.org Fri Nov 4 15:08:18 2016 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A6EBC2E822; Fri, 4 Nov 2016 15:08:18 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1DAB6DDF; Fri, 4 Nov 2016 15:08:18 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA4F8HAu084769; Fri, 4 Nov 2016 15:08:17 GMT (envelope-from gahr@FreeBSD.org) Received: (from gahr@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA4F8H5V084767; Fri, 4 Nov 2016 15:08:17 GMT (envelope-from gahr@FreeBSD.org) Message-Id: <201611041508.uA4F8H5V084767@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gahr set sender to gahr@FreeBSD.org using -f From: Pietro Cerutti Date: Fri, 4 Nov 2016 15:08:17 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r425329 - in head/lang/tcl86: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 15:08:18 -0000 Author: gahr Date: Fri Nov 4 15:08:17 2016 New Revision: 425329 URL: https://svnweb.freebsd.org/changeset/ports/425329 Log: lang/tcl86: fix integer overflow check and avoid segfault PR: 214205 Submitted by: gahr Added: head/lang/tcl86/files/patch-bug214205 (contents, props changed) Modified: head/lang/tcl86/Makefile Modified: head/lang/tcl86/Makefile ============================================================================== --- head/lang/tcl86/Makefile Fri Nov 4 15:04:47 2016 (r425328) +++ head/lang/tcl86/Makefile Fri Nov 4 15:08:17 2016 (r425329) @@ -3,7 +3,7 @@ PORTNAME= tcl PORTVERSION= 8.6.6 -PORTREVISION= 0 +PORTREVISION= 1 CATEGORIES= lang MASTER_SITES= SF/tcl/Tcl/${PORTVERSION} \ TCLTK/tcl8_6 Added: head/lang/tcl86/files/patch-bug214205 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lang/tcl86/files/patch-bug214205 Fri Nov 4 15:08:17 2016 (r425329) @@ -0,0 +1,64 @@ +Index: generic/tclListObj.c +================================================================== +--- generic/tclListObj.c ++++ generic/tclListObj.c +@@ -853,12 +853,15 @@ + */ + count = numElems - first; + } + + if (objc > LIST_MAX - (numElems - count)) { +- Tcl_SetObjResult(interp, Tcl_ObjPrintf( +- "max length of a Tcl list (%d elements) exceeded", LIST_MAX)); ++ if (interp != NULL) { ++ Tcl_SetObjResult(interp, Tcl_ObjPrintf( ++ "max length of a Tcl list (%d elements) exceeded", ++ LIST_MAX)); ++ } + return TCL_ERROR; + } + isShared = (listRepPtr->refCount > 1); + numRequired = numElems - count + objc; /* Known <= LIST_MAX */ + + +Index: generic/tclListObj.c +================================================================== +--- generic/tclListObj.c ++++ generic/tclListObj.c +@@ -895,15 +895,12 @@ + if (first >= numElems) { + first = numElems; /* So we'll insert after last element. */ + } + if (count < 0) { + count = 0; +- } else if (numElems < first+count || first+count < 0) { +- /* +- * The 'first+count < 0' condition here guards agains integer +- * overflow in determining 'first+count'. +- */ ++ } else if (first > INT_MAX - count /* Handle integer overflow */ ++ || numElems < first+count) { + + count = numElems - first; + } + + if (objc > LIST_MAX - (numElems - count)) { + +Index: generic/tclEnsemble.c +================================================================== +--- generic/tclEnsemble.c ++++ generic/tclEnsemble.c +@@ -3133,11 +3133,11 @@ + /* + * The length of the "replaced" list must be depth-1. Trim back + * any extra elements that might have been appended by failing + * pathways above. + */ +- (void) Tcl_ListObjReplace(NULL, replaced, depth-1, INT_MAX, 0, NULL); ++ (void) Tcl_ListObjReplace(NULL, replaced, depth-1, LIST_MAX, 0, NULL); + + /* + * TODO: Reconsider whether we ought to call CompileToInvokedCommand() + * when depth==1. In that case we are choosing to emit the + * INST_INVOKE_REPLACE bytecode when there is in fact no replacing +