This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix BZ #18660 -- overflow in getusershell


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]