Move from memmove to memmove_s.
Change-Id: I791029d82c2ed6d3d9f23eada87730ae037c9b6c
diff --git a/src/std.c b/src/std.c
index b7ea2ce..fd52a0f 100644
--- a/src/std.c
+++ b/src/std.c
@@ -21,6 +21,7 @@
/* Declare unsafe functions locally so they are not available globally. */
void *memset(void *s, int c, size_t n);
void *memcpy(void *dst, const void *src, size_t n);
+void *memmove(void *dst, const void *src, size_t n);
void memset_s(void *dest, rsize_t destsz, int ch, rsize_t count)
{
@@ -78,3 +79,24 @@
fail:
panic("memcpy_s failure");
}
+
+void memmove_s(void *dest, rsize_t destsz, const void *src, rsize_t count)
+{
+ if (dest == NULL || src == NULL) {
+ goto fail;
+ }
+
+ if (destsz > RSIZE_MAX || count > RSIZE_MAX) {
+ goto fail;
+ }
+
+ if (count > destsz) {
+ goto fail;
+ }
+
+ memmove(dest, src, count);
+ return;
+
+fail:
+ panic("memmove_s failure");
+}