Re: cut: Fix segmentation fault

2018-03-28 Thread Tobias Stoeckmann
Hi, On Wed, Mar 28, 2018 at 12:53:47AM +0200, Ingo Schwarze wrote: > Ouch, you are right. But then, the code feels counter-intuitive > and the error message confusing. I agree. Talking about a zero out of nothing seems weird, even though I have learned yesterday that "a=''; echo $((a))" is "0".

Re: cut: Fix segmentation fault

2018-03-27 Thread Ingo Schwarze
Hi Tobias, Tobias Stoeckmann wrote on Tue, Mar 27, 2018 at 11:51:29PM +0200: > On Tue, Mar 27, 2018 at 11:47:27PM +0200, Ingo Schwarze wrote: >> See inline for one optional suggestion. >>> if (!stop || !start) >>> errx(1, "[-bcf] list: values may not include zero"

Re: cut: Fix segmentation fault

2018-03-27 Thread Tobias Stoeckmann
On Tue, Mar 27, 2018 at 11:47:27PM +0200, Ingo Schwarze wrote: > See inline for one optional suggestion. > > > if (!stop || !start) > > errx(1, "[-bcf] list: values may not include zero"); > > Consider deleting these two lines, too. > > You new function read_numbe

Re: cut: Fix segmentation fault

2018-03-27 Thread Ingo Schwarze
Hi Tobias, Tobias Stoeckmann wrote on Tue, Mar 27, 2018 at 01:30:03PM +0200: > This patch fixes an out of boundary write in cut: > > $ cut -c 2147483648 - > Segmentation fault (core dumped) > > The supplied number can be parsed by strtol, but the result is casted > into a signed int, therefore

cut: Fix segmentation fault

2018-03-27 Thread Tobias Stoeckmann
This patch fixes an out of boundary write in cut: $ cut -c 2147483648 - Segmentation fault (core dumped) The supplied number can be parsed by strtol, but the result is casted into a signed int, therefore turning negative. Afterwards, it is used as an offset into a char array to write data at the