This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC/PATCH] memcpy-ssse3: add overlap checks
On Tue, Apr 12, 2011 at 7:54 PM, Ulrich Drepper <drepper@gmail.com> wrote:
> No. ÂThis does not belong into the production code.
>
> If you have crappy code to run which is not adequately tested then
> handle this outside the libc. ÂJust use a preloadable module. ÂIt's
> trivial, you can even add it to /etc/ld.so.preload. ÂUse code like
Ok, I didn't know it was possible to have an ld preload systemwide, I
searched for that but somehow didn't find it.
Here's my proposal for the check though:
---
#include <string.h>
extern void __fortify_fail(const char *msg);
void *memcpy(void *dst, const void *src, size_t n)
{
if (dst >= src + n || src >= dst + n)
goto ok;
__fortify_fail("memcpy overlap");
ok:
return memmove(dst, src, n);
}
---
--
Felipe Contreras