diff options
author | libuv upstream <libuv@googlegroups.com> | 2019-01-15 15:42:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-01-16 19:48:27 (GMT) |
commit | 4fcb0d0213112bb2fdb04bb27e82543b93cfe41d (patch) | |
tree | 746a72d3795b562075d66fab8947dfd7527b6044 /src/inet.c | |
parent | c8b67ea119c4000018238f6c3201a1364356d93a (diff) | |
download | CMake-4fcb0d0213112bb2fdb04bb27e82543b93cfe41d.zip CMake-4fcb0d0213112bb2fdb04bb27e82543b93cfe41d.tar.gz CMake-4fcb0d0213112bb2fdb04bb27e82543b93cfe41d.tar.bz2 |
libuv 2019-01-15 (f84c5e69)
Code extracted from:
https://github.com/libuv/libuv.git
at commit f84c5e693b80cb0c62bcefba147e7a66e2b839c9 (v1.x).
Diffstat (limited to 'src/inet.c')
-rw-r--r-- | src/inet.c | 13 |
1 files changed, 3 insertions, 10 deletions
@@ -19,7 +19,7 @@ #include <string.h> #if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" +# include "uv/stdint-msvc2008.h" #else # include <stdint.h> #endif @@ -59,8 +59,7 @@ static int inet_ntop4(const unsigned char *src, char *dst, size_t size) { if (l <= 0 || (size_t) l >= size) { return UV_ENOSPC; } - strncpy(dst, tmp, size); - dst[size - 1] = '\0'; + uv__strscpy(dst, tmp, size); return 0; } @@ -142,14 +141,8 @@ static int inet_ntop6(const unsigned char *src, char *dst, size_t size) { if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words)) *tp++ = ':'; *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { + if (UV_E2BIG == uv__strscpy(dst, tmp, size)) return UV_ENOSPC; - } - strcpy(dst, tmp); return 0; } |