diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-12-11 06:21:23 -0600 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-12-12 14:35:38 +0100 |
commit | c7b06385926349e10b3739314d1d56eec7efb8be (patch) | |
tree | 3a79abf2fcf4c267b7da9c2ac44c8ade74fdbb32 /nuttx | |
parent | 2b5e47b02a90f0dc8e6662523b05289670b722e3 (diff) | |
download | px4-nuttx-c7b06385926349e10b3739314d1d56eec7efb8be.tar.gz px4-nuttx-c7b06385926349e10b3739314d1d56eec7efb8be.tar.bz2 px4-nuttx-c7b06385926349e10b3739314d1d56eec7efb8be.zip |
strncpy: Commit d0c76ccacf0dc8988f9617ad82bf4349f456bb08 will trash a lot of memory if n == 0. From Hiro
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/libc/string/lib_strncpy.c | 2 |
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; } |