diff options
Diffstat (limited to 'deps/uv/test')
-rw-r--r-- | deps/uv/test/runner-unix.c | 2 | ||||
-rw-r--r-- | deps/uv/test/task.h | 28 | ||||
-rw-r--r-- | deps/uv/test/test-ip6-addr.c | 4 |
3 files changed, 31 insertions, 3 deletions
diff --git a/deps/uv/test/runner-unix.c b/deps/uv/test/runner-unix.c index b66df51b98..9afcd1e488 100644 --- a/deps/uv/test/runner-unix.c +++ b/deps/uv/test/runner-unix.c @@ -49,7 +49,7 @@ void platform_init(int argc, char **argv) { /* Disable stdio output buffering. */ setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); - strcpy(executable_path, argv[0]); + strncpy(executable_path, argv[0], sizeof(executable_path) - 1); signal(SIGPIPE, SIG_IGN); } diff --git a/deps/uv/test/task.h b/deps/uv/test/task.h index 6f96a4ff00..e050dca0c6 100644 --- a/deps/uv/test/task.h +++ b/deps/uv/test/task.h @@ -153,4 +153,32 @@ enum test_status { return TEST_SKIP; \ } while (0) +#ifdef _WIN32 + +#include <stdarg.h> + +/* Emulate snprintf() on Windows, _snprintf() doesn't zero-terminate the buffer + * on overflow... + */ +static int snprintf(char* buf, size_t len, const char* fmt, ...) { + va_list ap; + int n; + + va_start(ap, fmt); + n = _vsprintf_p(buf, len, fmt, ap); + va_end(ap); + + /* It's a sad fact of life that no one ever checks the return value of + * snprintf(). Zero-terminating the buffer hopefully reduces the risk + * of gaping security holes. + */ + if (n < 0) + if (len > 0) + buf[0] = '\0'; + + return n; +} + +#endif + #endif /* TASK_H_ */ diff --git a/deps/uv/test/test-ip6-addr.c b/deps/uv/test/test-ip6-addr.c index d65043eab6..9cd9b97cf1 100644 --- a/deps/uv/test/test-ip6-addr.c +++ b/deps/uv/test/test-ip6-addr.c @@ -76,9 +76,9 @@ void test_ip6_addr_scope(const char* ip6_addr, if (strncmp(ip6_addr, "fe80::", 6) != 0) return; #ifdef _WIN32 - sprintf(scoped_addr, "%s%%%d", ip6_addr, iface_index); + snprintf(scoped_addr, sizeof(scoped_addr), "%s%%%d", ip6_addr, iface_index); #else - sprintf(scoped_addr, "%s%%%s", ip6_addr, device_name); + snprintf(scoped_addr, sizeof(scoped_addr), "%s%%%s", ip6_addr, device_name); #endif LOGF("Testing link-local address %s (iface_index: 0x%02x, device_name: %s)\n", |