strncpy: Commit d0c76ccacf0dc8988f9617ad82bf4349f456bb08 will trash a lot of memory if n == 0. From Hiro
This commit is contained in:
parent
c1ecf8c449
commit
554f56b99d
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user