strncpy: Commit d0c76ccacf0dc8988f9617ad82bf4349f456bb08 will trash a lot of memory if n == 0. From Hiro

This commit is contained in:
Gregory Nutt 2014-12-11 06:21:23 -06:00
parent c1ecf8c449
commit 554f56b99d

View File

@ -55,7 +55,7 @@ char *strncpy(FAR char *dest, FAR const char *src, size_t n)
char *ret = dest; /* Value to be returned */
char *end = dest + n; /* End of dest buffer + 1 byte */
while ((*dest++ = *src++) != '\0' && dest != end);
while ((dest != end) && (*dest++ = *src++) != '\0');
while (dest != end) *dest++ = '\0';
return ret;
}