From owner-svn-src-head@FreeBSD.ORG Wed Nov 9 08:36:00 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6DEA106566B; Wed, 9 Nov 2011 08:36:00 +0000 (UTC) (envelope-from stefan@fafoe.narf.at) Received: from fep12.mx.upcmail.net (fep12.mx.upcmail.net [62.179.121.32]) by mx1.freebsd.org (Postfix) with ESMTP id 96D8F8FC0C; Wed, 9 Nov 2011 08:35:59 +0000 (UTC) Received: from edge04.upcmail.net ([192.168.13.239]) by viefep12-int.chello.at (InterMail vM.8.01.02.02 201-2260-120-106-20100312) with ESMTP id <20111109083557.KQNH1724.viefep12-int.chello.at@edge04.upcmail.net>; Wed, 9 Nov 2011 09:35:57 +0100 Received: from mole.fafoe.narf.at ([213.47.85.26]) by edge04.upcmail.net with edge id uwbs1h00p0a5KZh04wbtEM; Wed, 09 Nov 2011 09:35:57 +0100 X-SourceIP: 213.47.85.26 Received: by mole.fafoe.narf.at (Postfix, from userid 1001) id 412B66D421; Wed, 9 Nov 2011 09:35:51 +0100 (CET) Date: Wed, 9 Nov 2011 09:35:51 +0100 From: Stefan Farfeleder To: Jilles Tjoelker Message-ID: <20111109083545.GC1598@mole.fafoe.narf.at> References: <201111082354.pA8NsdhP055080@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201111082354.pA8NsdhP055080@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Cloudmark-Analysis: v=1.1 cv=7AjrSHUygkxmgKj9+ZdWPzZoKYzIcpgZMIt1Yxqn8hE= c=1 sm=0 a=wom5GMh1gUkA:10 a=vtY-WIFys40A:10 a=dBRESv0yCI8A:10 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=mp3zRhi_tjVsM90RcpoA:9 a=_9n0mCyewBjp4DwR7fcA:7 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r227369 - head/bin/sh X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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, 09 Nov 2011 08:36:00 -0000 On Tue, Nov 08, 2011 at 11:54:39PM +0000, Jilles Tjoelker wrote: > Author: jilles > Date: Tue Nov 8 23:54:39 2011 > New Revision: 227369 > URL: http://svn.freebsd.org/changeset/base/227369 > > Log: > sh: Remove undefined behaviour due to overflow in +/-/* in arithmetic. > > With i386 base gcc and i386 base clang, arith_yacc.o remains unchanged. > > Modified: > head/bin/sh/arith_yacc.c > > Modified: head/bin/sh/arith_yacc.c > ============================================================================== > --- head/bin/sh/arith_yacc.c Tue Nov 8 23:44:26 2011 (r227368) > +++ head/bin/sh/arith_yacc.c Tue Nov 8 23:54:39 2011 (r227369) > @@ -131,11 +131,11 @@ static arith_t do_binop(int op, arith_t > yyerror("divide error"); > return op == ARITH_REM ? a % b : a / b; > case ARITH_MUL: > - return a * b; > + return (uintmax_t)a * (uintmax_t)b; > case ARITH_ADD: > - return a + b; > + return (uintmax_t)a + (uintmax_t)b; > case ARITH_SUB: > - return a - b; > + return (uintmax_t)a - (uintmax_t)b; > case ARITH_LSHIFT: > return a << b; > case ARITH_RSHIFT: > Isn't the behaviour undefined too when you convert an out-of-range uintmax_t value back into an intmax_t value? Stefan