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
- From: Ulrich Drepper <drepper at gmail dot com>
- To: Felipe Contreras <felipe dot contreras at gmail dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 12 Apr 2011 12:54:54 -0400
- Subject: Re: [RFC/PATCH] memcpy-ssse3: add overlap checks
- References: <1302534900-6838-1-git-send-email-felipe.contreras@gmail.com>
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
#include <stdint.h>
#include <string.h>
#include <unistd.h>
void *
memcpy (void *d, const void *s, size_t n)
{
if ((d < s && ((uintptr_t) d + n < (uintptr_t) d
|| (uintptr_t) d + n > (uintptr_t) s))
|| (d >= s && ((uintptr_t) s + n < (uintptr_t) s
|| (uintptr_t) s + n > (uintptr_t) d)))
write (2, "memcpy use error\n", 17);
return memmove (d, s, n);
}