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: [PING][PATCH] Improve str(n)cat_chk performance.


On Wed, Aug 26, 2015 at 05:52:39PM -0300, Adhemerval Zanella wrote:
> 
> 
> On 26-08-2015 13:43, OndÅej BÃlka wrote:
> > ping
> 
> >> -  while (c != '\0');
> >> +  size_t len = strlen (dest);
> >> +  size_t srclen = strlen (src);
> >>  
> >> +  if (__glibc_unlikely (len + srclen + 1 > destlen))
> >> +    __chk_fail ();
> 
> Couldn't this test potentially wrap over the unsigned operation?  I think
> we should add an extra test to avoid this:
>
As this calculates size of physical memory occupied such computations couldn't overflow unless there is overlap.

I send patch to also test overlaps in past I could dig it.

That would be better than adding checks for corner cases when user needs
to allocate string larger than half of address space and call strcat
with that one as both arguments.


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