summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-11-08 12:53:15 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-11-08 12:53:15 +0100
commit434575706930a762d7cb26e26cc26b140b453f65 (patch)
treebfbdccfb11bc3ac6e99377fc042cc91c4ae49a54 /util.c
parent6630673da74616ddac305aa5d38165fc05aadeaa (diff)
parent6b9dcbb04abee53b6561d690c077c048795c3874 (diff)
Merge branch 'release/debian/3.3-1' into masterdebian/3.3-1
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/util.c b/util.c
index eeffdae..04aaadd 100644
--- a/util.c
+++ b/util.c
@@ -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)
{