This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][BZ #15672] Fix error_tail overflow in allocation calculation.
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: <libc-alpha at sourceware dot org>
- Date: Mon, 14 Oct 2013 14:33:04 +0000
- Subject: Re: [PATCH][BZ #15672] Fix error_tail overflow in allocation calculation.
- Authentication-results: sourceware.org; auth=none
- References: <20131014125751 dot GA22906 at domone dot podge> <Pine dot LNX dot 4 dot 64 dot 1310141357570 dot 11037 at digraph dot polyomino dot org dot uk> <20131014140506 dot GA23643 at domone dot podge>
On Mon, 14 Oct 2013, Ondrej Bilka wrote:
> On Mon, Oct 14, 2013 at 01:59:17PM +0000, Joseph S. Myers wrote:
> > On Mon, 14 Oct 2013, Ondrej Bilka wrote:
> >
> > > @@ -165,7 +165,7 @@ error_tail (int status, int errnum, const char *message, va_list args)
> > > if (res != len)
> > > break;
> > >
> > > - if (__builtin_expect (len >= SIZE_MAX / 2, 0))
> > > + if (__builtin_expect (len * sizeof (wchar_t) >= SIZE_MAX / 2, 0))
> >
> > No, that's incorrect, as len * sizeof (wchar_t) can overflow size_t. You
> > need to compare len directly with SIZE_MAX / 2 / sizeof (wchar_t).
> >
> Ok with that?
Yes.
--
Joseph S. Myers
joseph@codesourcery.com