Once upon a time, John Reiser <jrei...@bitwagon.com> said:
> For right now (the immediate present) a work-around is to use the 'memmove'
> subroutine as the resolution of any reference to the symbol 'memcpy'.
> The quick-and-dirty way to do this

It would probably be easier to use an LD_PRELOAD to load a wrapper to
change memcpy() with overlaps to memmove().  This would obviously slow
down all memcpy() calls, but maybe it could just be used for Flash (or
at least just for plugins).  Something like (untested):


/* Library preload to replacing overlapping memcpy() with memmove()
 *
 * Compile with:
 *   gcc -O2 -ldl -fpic -shared -o preload-memcpy.so preload-memcpy.c
 * Use like
 *   LD_PRELOAD=/path/to/preload-memcpy.so; export LD_PRELOAD
 *   <some command>
 */

#define _GNU_SOURCE
#include <string.h>
#include <dlfcn.h>
#include <assert.h>

static void * (*real_memcpy) (void *dest, const void *src, size_t n);
void *memcpy (void *dest, const void *src, size_t n)
{
        char *d = (char *) dest;
        char *s = (char *) src;

        if (((d < s) && ((d + n - 1) >= s)) ||
            ((s < d) && ((s + n - 1) >= d)))
                return memmove (dest, src, n);
        if (! real_memcpy)
                assert (real_memcpy = dlsym (RTLD_NEXT, "memcpy"));
        return real_memcpy (dest, src, n);
}


-- 
Chris Adams <cmad...@hiwaay.net>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel

Reply via email to