summaryrefslogtreecommitdiffstats
path: root/src/inet.c
diff options
context:
space:
mode:
authorlibuv upstream <libuv@googlegroups.com>2019-01-15 15:42:13 (GMT)
committerBrad King <brad.king@kitware.com>2019-01-16 19:48:27 (GMT)
commit4fcb0d0213112bb2fdb04bb27e82543b93cfe41d (patch)
tree746a72d3795b562075d66fab8947dfd7527b6044 /src/inet.c
parentc8b67ea119c4000018238f6c3201a1364356d93a (diff)
downloadCMake-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.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/inet.c b/src/inet.c
index da63a68..698ab23 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -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;
}