Re: Doubt about an integer overflow in cut.c

2010-03-26 Thread Ted Unangst
If len + 1 == 0, that means the string is every byte but one, meaning there wouldn't be enough space for len and the string to coexist. On Mar 26, 2010, at 5:18 AM, Amarendra Godbole > wrote: cut.c has the following: [...] void f_cut(FILE *fp, char *fname) { int ch, field, isdelim; ch

Re: Doubt about an integer overflow in cut.c

2010-03-26 Thread Mark Kettenis
> Date: Fri, 26 Mar 2010 10:45:57 +0100 > From: Otto Moerbeek > > On Fri, Mar 26, 2010 at 02:48:58PM +0530, Amarendra Godbole wrote: > > > cut.c has the following: > > > > [...] > > void > > f_cut(FILE *fp, char *fname) > > { > > int ch, field, isdelim; > > char *pos, *p, sep; > > i

Re: Doubt about an integer overflow in cut.c

2010-03-26 Thread Otto Moerbeek
On Fri, Mar 26, 2010 at 02:48:58PM +0530, Amarendra Godbole wrote: > cut.c has the following: > > [...] > void > f_cut(FILE *fp, char *fname) > { > int ch, field, isdelim; > char *pos, *p, sep; > int output; > size_t len; > char *lbuf, *tbuf; > > for (sep = dchar, tbuf =

Doubt about an integer overflow in cut.c

2010-03-26 Thread Amarendra Godbole
cut.c has the following: [...] void f_cut(FILE *fp, char *fname) { int ch, field, isdelim; char *pos, *p, sep; int output; size_t len; char *lbuf, *tbuf; for (sep = dchar, tbuf = NULL; (lbuf = fgetln(fp, &len));) { output = 0; if (lbuf[len - 1] != '\n') {