diff options
Diffstat (limited to 'deps/uv/test/task.h')
-rw-r--r-- | deps/uv/test/task.h | 28 |
1 files changed, 28 insertions, 0 deletions
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_ */ |