On Sun, Jul 17, 2011 at 12:15:50PM +0200, Alexander Schrijver wrote: > On Sun, Jul 17, 2011 at 11:32:27AM +0200, Otto Moerbeek wrote: > > On Sun, Jul 17, 2011 at 11:20:28AM +0200, Alexander Schrijver wrote: > > > > > This fixes an integer overflow with very long lines. > > > > > > OK? > > > > Hmm, changing from a signed to an unsigned type might lead to > > surprises. I think regoff_t is better. > > Makes sense. This is what used by regmatch_t members anyways. When opening the > file there is a check the file is not larger than SIZE_T_MAX. Does a size_t > always fit into a regoff_t?
nope, only ssize_t is guaranteed. -Otto > > new diff > > Index: util.c > =================================================================== > RCS file: /home/alex/scm/cvsync/src/usr.bin/grep/util.c,v > retrieving revision 1.41 > diff -u -r1.41 util.c > --- util.c 11 Jul 2011 20:43:21 -0000 1.41 > +++ util.c 17 Jul 2011 10:03:56 -0000 > @@ -169,7 +169,7 @@ > { > regmatch_t pmatch; > int c, i, r; > - int offset; > + regoff_t offset; > > c = 0; > i = 0; > @@ -444,7 +444,7 @@ > #ifdef SMALL > return 0; > #else > - int j; > + regoff_t j; > int rtrnVal = REG_NOMATCH; > > pmatch->rm_so = -1;