diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-10-17 09:29:59 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-10-17 09:29:59 +0200 |
commit | ebef811fce038c382fb66ecd728c9d885460263b (patch) | |
tree | a8630403c5091a3e4f3a86c682262337613fae2c /util.c | |
parent | 7c994b7f6bda56308e5f1d50651d5951de92198f (diff) |
New upstream version 3.3upstream/3.3
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -155,6 +155,18 @@ out: return p; } +static void safe_memcpy(void *dest, const void *src, size_t n) +{ +#ifdef USE_SLOW_MEMCPY + size_t i; + + for (i = 0; i < n; i++) + *((u8 *)dest + i) = *((const u8 *)src + i); +#else + memcpy(dest, src, n); +#endif +} + /* * Copy a physical memory chunk into a memory buffer. * This function allocates memory. @@ -214,7 +226,7 @@ void *mem_chunk(off_t base, size_t len, const char *devmem) if (mmp == MAP_FAILED) goto try_read; - memcpy(p, (u8 *)mmp + mmoffset, len); + safe_memcpy(p, (u8 *)mmp + mmoffset, len); if (munmap(mmp, mmoffset + len) == -1) { |