Re: Overflowable int -> size_t in grep

2015-12-07 Thread Todd C. Miller
On Mon, 07 Dec 2015 02:32:50 -0500, Michael McConville wrote: > Does this look better? Or is PRId64 preferred for off_t? As Otto said, we generally use %lld for printing off_t and use a (long long) cast. With that change OK millert@ - todd

Re: Overflowable int -> size_t in grep

2015-12-07 Thread Theo de Raadt
> > Otto Moerbeek wrote: > > > On Mon, Dec 07, 2015 at 01:36:22AM -0500, Michael McConville wrote: > > > > This isn't a grave issue, but I came across it while exploring integer > > > > overflow and think it's worth sharing. > > > > > > > > grep represents line numbers with an int, which predictab

Re: Overflowable int -> size_t in grep

2015-12-07 Thread Otto Moerbeek
On Mon, Dec 07, 2015 at 02:32:50AM -0500, Michael McConville wrote: > Otto Moerbeek wrote: > > On Mon, Dec 07, 2015 at 01:36:22AM -0500, Michael McConville wrote: > > > This isn't a grave issue, but I came across it while exploring integer > > > overflow and think it's worth sharing. > > > > > >

Re: Overflowable int -> size_t in grep

2015-12-07 Thread Joerg Sonnenberger
On Mon, Dec 07, 2015 at 02:32:50AM -0500, Michael McConville wrote: > Otto Moerbeek wrote: > > On Mon, Dec 07, 2015 at 01:36:22AM -0500, Michael McConville wrote: > > > This isn't a grave issue, but I came across it while exploring integer > > > overflow and think it's worth sharing. > > > > > > g

Re: Overflowable int -> size_t in grep

2015-12-06 Thread Michael McConville
Otto Moerbeek wrote: > On Mon, Dec 07, 2015 at 01:36:22AM -0500, Michael McConville wrote: > > This isn't a grave issue, but I came across it while exploring integer > > overflow and think it's worth sharing. > > > > grep represents line numbers with an int, which predictably overflows > > for inp

Re: Overflowable int -> size_t in grep

2015-12-06 Thread Otto Moerbeek
On Mon, Dec 07, 2015 at 01:36:22AM -0500, Michael McConville wrote: > This isn't a grave issue, but I came across it while exploring integer > overflow and think it's worth sharing. > > grep represents line numbers with an int, which predictably overflows > for inputs with >= 2^31 newlines. This

Re: Overflowable int -> size_t in grep

2015-12-06 Thread Michael McConville
Michael McConville wrote: > This isn't a grave issue, but I came across it while exploring integer > overflow and think it's worth sharing. > > grep represents line numbers with an int, which predictably overflows > for inputs with >= 2^31 newlines. This is easy to demonstrate using the > -n optio

Overflowable int -> size_t in grep

2015-12-06 Thread Michael McConville
This isn't a grave issue, but I came across it while exploring integer overflow and think it's worth sharing. grep represents line numbers with an int, which predictably overflows for inputs with >= 2^31 newlines. This is easy to demonstrate using the -n option and a debugging printf. The below d