[RFC/PATCH] memcpy-ssse3: add overlap checks
Ulrich Drepper
drepper@gmail.com
Tue Apr 12 16:57:00 GMT 2011
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);
}
More information about the Libc-alpha
mailing list