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: [RFC/PATCH] memcpy-ssse3: add overlap checks


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);
}


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