lib: string: compile strlcat() and memscpy()
Make strlcat() and memscpy() function
as compilable by removing unnecessary
things.
Change-Id: I77759fbf7e150a169d9a756542c806493e85e183
Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
diff --git a/lib/string.c b/lib/string.c
index 0dec46c..233adee 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -200,7 +200,6 @@
dest[len] = 0;
return res;
}
-EXPORT_SYMBOL(strlcat);
#endif
#ifndef __HAVE_ARCH_STRCMP
@@ -548,11 +547,30 @@
}
#endif
-size_t memscpy(void *dest, size_t dst_size, const void *src, size_t copy_size) {
+#ifndef __HAVE_ARCH_MEMSCPY
+/**
+ * memscpy - Copy one area of memory to another
+ * @dest: Where to copy to
+ * @src: Where to copy from
+ * @dst_size: The size of destination buffer area
+ * @copy_size: The size of source buffer area
+ *
+ * You should not use this function where memcpy
+ * was used to copy null terminated buffer, the
+ * replacement function is strlcpy() and strlcat()
+ * depending on situation.
+ *
+ * The aim of memscpy() is to prevent buffer overflow
+ * by taking both destination buffer size and source
+ * buffer size.
+ */
+size_t memscpy(void *dest, size_t dst_size, const void *src, size_t copy_size)
+{
size_t min_size = dst_size < copy_size ? dst_size : copy_size;
memcpy(dest, src, min_size);
return min_size;
}
+#endif
#ifndef __HAVE_ARCH_MEMMOVE
/**