mirror of
https://github.com/apache/nuttx.git
synced 2026-08-08 22:17:18 +00:00
strncpy: Commit d0c76ccacf0dc8988f9617ad82bf4349f456bb08 will trash a lot of memory if n == 0. From Hiro
This commit is contained in:
parent
c1ecf8c449
commit
554f56b99d
1 changed files with 1 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue