Re: expr: Fix integer overflows

2018-03-31 Thread Ingo Schwarze
Hi Tobias, Tobias Stoeckmann wrote on Sat, Mar 31, 2018 at 01:28:19PM +0200: > I actually ended up in expr(1) after seeing that the test(1) and ksh(1) > debate could be continued here. While expr(1) is int64_t, expressions > in ksh(1) are of type long, i.e. 32/64 bit depending on architecture. >

Re: expr: Fix integer overflows

2018-03-31 Thread Tobias Stoeckmann
Hi, On Sat, Mar 31, 2018 at 02:57:45AM +0200, Ingo Schwarze wrote: > Even though - as discussed previously for test(1) - behaviour is > undefined by POSIX outside the range 0 to 2147483647, we are allowed > to handle a larger range, and i agree that handling the range > -9223372036854775808 to 922

Re: expr: Fix integer overflows

2018-03-30 Thread Ingo Schwarze
Hi Tobias, Tobias Stoeckmann wrote on Fri, Mar 30, 2018 at 05:39:11PM +0200: > Our expr implementation supports 64 bit integers, but does not check > for overflows during parsing and arithmetical operations. Even though - as discussed previously for test(1) - behaviour is undefined by POSIX outs

expr: Fix integer overflows

2018-03-30 Thread Tobias Stoeckmann
Our expr implementation supports 64 bit integers, but does not check for overflows during parsing and arithmetical operations. This patch fixes the problems based on FreeBSD's implementation, which is a bit more advanced than NetBSD, which it is based upon. The added regression test case is taken