This is the mail archive of the
mailing list for the glibc project.
Re: [PING][PATCH] Improve str(n)cat_chk performance.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 27 Aug 2015 08:28:40 +0200
- Subject: Re: [PING][PATCH] Improve str(n)cat_chk performance.
- Authentication-results: sourceware.org; auth=none
- References: <20150820073517 dot GA6785 at domone> <20150826164303 dot GA27006 at domone> <55DE2717 dot 5050605 at linaro dot org>
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.