strlcpy: make more robust
authorAlan Cox <alan@linux.intel.com>
Mon, 22 Jan 2018 00:09:09 +0000 (00:09 +0000)
committerAlan Cox <alan@linux.intel.com>
Mon, 22 Jan 2018 00:09:09 +0000 (00:09 +0000)
Library/libs/strlcpy.c

index e565d8b..f4d2cf6 100644 (file)
@@ -2,7 +2,7 @@
 
 size_t strlcpy(char *dst, const char *src, size_t dstsize)
 {
-  size_t len = strlen(src);
+  size_t len = strnlen(src, dstsize);
   size_t cp = len >= dstsize ? dstsize - 1 : len;
   memcpy(dst, src, cp);
   dst[cp] = 0;