summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-12-11 06:21:23 -0600
committerLorenz Meier <lm@inf.ethz.ch>2014-12-12 14:35:38 +0100
commitc7b06385926349e10b3739314d1d56eec7efb8be (patch)
tree3a79abf2fcf4c267b7da9c2ac44c8ade74fdbb32
parent2b5e47b02a90f0dc8e6662523b05289670b722e3 (diff)
downloadnuttx-c7b06385926349e10b3739314d1d56eec7efb8be.tar.gz
nuttx-c7b06385926349e10b3739314d1d56eec7efb8be.tar.bz2
nuttx-c7b06385926349e10b3739314d1d56eec7efb8be.zip
strncpy: Commit d0c76ccacf0dc8988f9617ad82bf4349f456bb08 will trash a lot of memory if n == 0. From Hiro
-rw-r--r--nuttx/libc/string/lib_strncpy.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/nuttx/libc/string/lib_strncpy.c b/nuttx/libc/string/lib_strncpy.c
index 8dfc899ce..5bd8ab237 100644
--- a/nuttx/libc/string/lib_strncpy.c
+++ b/nuttx/libc/string/lib_strncpy.c
@@ -51,7 +51,7 @@ char *strncpy(char *dest, 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;
}