[patch] Fix BZ #18660 -- overflow in getusershell
Joseph Myers
joseph@codesourcery.com
Mon Aug 17 15:48:00 GMT 2015
On Mon, 17 Aug 2015, Tobias Stöckmann wrote:
> > On August 17, 2015 at 12:59 PM Joseph Myers <joseph@codesourcery.com> wrote:
> > Since you're increasing an allocation size, don't you also need to adjust
> > the check a few lines earlier for whether the allocation size calculation
> > would overflow?
>
> if (statb.st_size > ~(size_t)0 / sizeof (char *) * 3)
> goto init_okshells;
> flen = statb.st_size + 3;
>
> The check has to focus on flen's statb.st_size + 3 anyway.
> It's larger than statb.st_size / 3.
It's smaller than statb.st_size / 3 * sizeof (char *) (or the new adjusted
version thereof), since sizeof (char *) is 4 or 8 for configurations
supported by glibc.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list