deps: upgrade to libuv 1.24.1

PR-URL: https://github.com/nodejs/node/pull/25078
Fixes: https://github.com/nodejs/node/issues/24521
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
cjihrig 2018-12-16 14:18:16 -05:00
parent e1ab457490
commit 728b155870
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
60 changed files with 422 additions and 128 deletions

2
deps/uv/.gitignore vendored
View File

@ -42,7 +42,7 @@ Makefile.in
/android-toolchain /android-toolchain
/out/ /out/
/build/gyp /build/
/test/.libs/ /test/.libs/
/test/run-tests /test/run-tests

6
deps/uv/AUTHORS vendored
View File

@ -356,3 +356,9 @@ hitesh <sainihitesh.scientist@gmail.com>
Svante Signell <svante.signell@gmail.com> Svante Signell <svante.signell@gmail.com>
Samuel Thibault <sthibault@debian.org> Samuel Thibault <sthibault@debian.org>
Jeremy Studer <studerj1.mail@gmail.com> Jeremy Studer <studerj1.mail@gmail.com>
damon-kwok <563066990@qq.com>
Damon Kwok <MedusaIDE@outlook.com>
Ashe Connor <ashe@kivikakk.ee>
Rick <lcw0622@163.com>
Ivan Krylov <krylov.r00t@gmail.com>
Michael Meier <michael.meier@leica-geosystems.com>

View File

@ -15,6 +15,7 @@ set(uv_sources
src/fs-poll.c src/fs-poll.c
src/idna.c src/idna.c
src/inet.c src/inet.c
src/strscpy.c
src/threadpool.c src/threadpool.c
src/timer.c src/timer.c
src/uv-common.c src/uv-common.c
@ -116,6 +117,7 @@ set(uv_test_sources
test/test-socket-buffer-size.c test/test-socket-buffer-size.c
test/test-spawn.c test/test-spawn.c
test/test-stdio-over-pipes.c test/test-stdio-over-pipes.c
test/test-strscpy.c
test/test-tcp-alloc-cb-fail.c test/test-tcp-alloc-cb-fail.c
test/test-tcp-bind-error.c test/test-tcp-bind-error.c
test/test-tcp-bind6-error.c test/test-tcp-bind6-error.c
@ -208,7 +210,11 @@ if(WIN32)
list(APPEND uv_test_sources src/win/snprintf.c test/runner-win.c) list(APPEND uv_test_sources src/win/snprintf.c test/runner-win.c)
else() else()
list(APPEND uv_defines _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE) list(APPEND uv_defines _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
# Android has pthread as part of its c library, not as a separate
# libpthread.so.
list(APPEND uv_libraries pthread) list(APPEND uv_libraries pthread)
endif()
list(APPEND uv_sources list(APPEND uv_sources
src/unix/async.c src/unix/async.c
src/unix/core.c src/unix/core.c

33
deps/uv/ChangeLog vendored
View File

@ -1,3 +1,36 @@
2018.12.17, Version 1.24.1 (Stable), 274f2bd3b70847cadd9a3965577a87e666ab9ac3
Changes since version 1.24.0:
* test: fix platform_output test on cygwin (damon-kwok)
* gitignore: ignore build/ directory (Damon Kwok)
* unix: zero epoll_event before use (Ashe Connor)
* darwin: use runtime check for file cloning (Ben Noordhuis)
* doc: replace deprecated build command on macOS (Rick)
* warnings: fix code that emits compiler warnings (Jameson Nash)
* doc: clarify expected memory management strategy (Ivan Krylov)
* test: add uv_inet_ntop(AF_INET) coverage (Ben Noordhuis)
* unix: harden string copying, introduce strscpy() (Ben Noordhuis)
* linux: get rid of strncpy() call (Ben Noordhuis)
* aix: get rid of strcat() calls (Ben Noordhuis)
* aix: fix data race in uv_fs_event_start() (Ben Noordhuis)
* win: fs: fix `FILE_FLAG_NO_BUFFERING` for writes (Joran Dirk Greef)
* build: don't link against -lpthread on Android (Michael Meier)
2018.11.14, Version 1.24.0 (Stable), 2d427ee0083d1baf995df4ebf79a3f8890e9a3e1 2018.11.14, Version 1.24.0 (Stable), 2d427ee0083d1baf995df4ebf79a3f8890e9a3e1
Changes since version 1.23.2: Changes since version 1.23.2:

3
deps/uv/Makefile.am vendored
View File

@ -32,6 +32,8 @@ libuv_la_SOURCES = src/fs-poll.c \
src/idna.c \ src/idna.c \
src/inet.c \ src/inet.c \
src/queue.h \ src/queue.h \
src/strscpy.c \
src/strscpy.h \
src/threadpool.c \ src/threadpool.c \
src/timer.c \ src/timer.c \
src/uv-data-getter-setters.c \ src/uv-data-getter-setters.c \
@ -241,6 +243,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/test-socket-buffer-size.c \ test/test-socket-buffer-size.c \
test/test-spawn.c \ test/test-spawn.c \
test/test-stdio-over-pipes.c \ test/test-stdio-over-pipes.c \
test/test-strscpy.c \
test/test-tcp-alloc-cb-fail.c \ test/test-tcp-alloc-cb-fail.c \
test/test-tcp-bind-error.c \ test/test-tcp-bind-error.c \
test/test-tcp-bind6-error.c \ test/test-tcp-bind6-error.c \

3
deps/uv/README.md vendored
View File

@ -262,8 +262,7 @@ Run:
```bash ```bash
$ ./gyp_uv.py -f xcode $ ./gyp_uv.py -f xcode
$ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \ $ xcodebuild -ARCHS="x86_64" -project out/uv.xcodeproj -configuration Release -alltargets
-configuration Release -target All
``` ```
Using Homebrew: Using Homebrew:

View File

@ -13,7 +13,7 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT([libuv], [1.24.0], [https://github.com/libuv/libuv/issues]) AC_INIT([libuv], [1.24.1], [https://github.com/libuv/libuv/issues])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/libuv-extra-automake-flags.m4])
m4_include([m4/as_case.m4]) m4_include([m4/as_case.m4])

View File

@ -140,6 +140,8 @@ API
Request handle to be closed. `close_cb` will be called asynchronously after Request handle to be closed. `close_cb` will be called asynchronously after
this call. This MUST be called on each handle before memory is released. this call. This MUST be called on each handle before memory is released.
Moreover, the memory can only be released in `close_cb` or after it has
returned.
Handles that wrap file descriptors are closed immediately but Handles that wrap file descriptors are closed immediately but
`close_cb` will still be deferred to the next iteration of the event loop. `close_cb` will still be deferred to the next iteration of the event loop.

View File

@ -32,7 +32,7 @@
#define UV_VERSION_MAJOR 1 #define UV_VERSION_MAJOR 1
#define UV_VERSION_MINOR 24 #define UV_VERSION_MINOR 24
#define UV_VERSION_PATCH 0 #define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_IS_RELEASE 1
#define UV_VERSION_SUFFIX "" #define UV_VERSION_SUFFIX ""

View File

@ -25,6 +25,7 @@
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
typedef intptr_t ssize_t; typedef intptr_t ssize_t;
# define SSIZE_MAX INTPTR_MAX
# define _SSIZE_T_ # define _SSIZE_T_
# define _SSIZE_T_DEFINED # define _SSIZE_T_DEFINED
#endif #endif

11
deps/uv/src/inet.c vendored
View File

@ -59,8 +59,7 @@ static int inet_ntop4(const unsigned char *src, char *dst, size_t size) {
if (l <= 0 || (size_t) l >= size) { if (l <= 0 || (size_t) l >= size) {
return UV_ENOSPC; return UV_ENOSPC;
} }
strncpy(dst, tmp, size); uv__strscpy(dst, tmp, size);
dst[size - 1] = '\0';
return 0; 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)) if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words))
*tp++ = ':'; *tp++ = ':';
*tp++ = '\0'; *tp++ = '\0';
if (UV_E2BIG == uv__strscpy(dst, tmp, size))
/*
* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size) {
return UV_ENOSPC; return UV_ENOSPC;
}
strcpy(dst, tmp);
return 0; return 0;
} }

17
deps/uv/src/strscpy.c vendored Normal file
View File

@ -0,0 +1,17 @@
#include "strscpy.h"
#include <limits.h> /* SSIZE_MAX */
ssize_t uv__strscpy(char* d, const char* s, size_t n) {
size_t i;
for (i = 0; i < n; i++)
if ('\0' == (d[i] = s[i]))
return i > SSIZE_MAX ? UV_E2BIG : (ssize_t) i;
if (i == 0)
return 0;
d[--i] = '\0';
return UV_E2BIG;
}

18
deps/uv/src/strscpy.h vendored Normal file
View File

@ -0,0 +1,18 @@
#ifndef UV_STRSCPY_H_
#define UV_STRSCPY_H_
/* Include uv.h for its definitions of size_t and ssize_t.
* size_t can be obtained directly from <stddef.h> but ssize_t requires
* some hoop jumping on Windows that I didn't want to duplicate here.
*/
#include "uv.h"
/* Copies up to |n-1| bytes from |d| to |s| and always zero-terminates
* the result, except when |n==0|. Returns the number of bytes copied
* or UV_E2BIG if |d| is too small.
*
* See https://www.kernel.org/doc/htmldocs/kernel-api/API-strscpy.html
*/
ssize_t uv__strscpy(char* d, const char* s, size_t n);
#endif /* UV_STRSCPY_H_ */

2
deps/uv/src/timer.c vendored
View File

@ -152,7 +152,7 @@ int uv__next_timeout(const uv_loop_t* loop) {
if (diff > INT_MAX) if (diff > INT_MAX)
diff = INT_MAX; diff = INT_MAX;
return diff; return (int) diff;
} }

View File

@ -358,19 +358,15 @@ void uv_loadavg(double avg[3]) {
#ifdef HAVE_SYS_AHAFS_EVPRODS_H #ifdef HAVE_SYS_AHAFS_EVPRODS_H
static char *uv__rawname(char *cp) { static char* uv__rawname(const char* cp, char (*dst)[FILENAME_MAX+1]) {
static char rawbuf[FILENAME_MAX+1]; char* dp;
char *dp = rindex(cp, '/');
dp = rindex(cp, '/');
if (dp == 0) if (dp == 0)
return 0; return 0;
*dp = 0; snprintf(*dst, sizeof(*dst), "%.*s/r%s", (int) (dp - cp), cp, dp + 1);
strcpy(rawbuf, cp); return *dst;
*dp = '/';
strcat(rawbuf, "/r");
strcat(rawbuf, dp+1);
return rawbuf;
} }
@ -399,6 +395,7 @@ static int uv__path_is_a_directory(char* filename) {
* Returns 0 if AHAFS is mounted, or an error code < 0 on failure * Returns 0 if AHAFS is mounted, or an error code < 0 on failure
*/ */
static int uv__is_ahafs_mounted(void){ static int uv__is_ahafs_mounted(void){
char rawbuf[FILENAME_MAX+1];
int rv, i = 2; int rv, i = 2;
struct vmount *p; struct vmount *p;
int size_multiplier = 10; int size_multiplier = 10;
@ -432,7 +429,7 @@ static int uv__is_ahafs_mounted(void){
obj = vmt2dataptr(vmt, VMT_OBJECT); /* device */ obj = vmt2dataptr(vmt, VMT_OBJECT); /* device */
stub = vmt2dataptr(vmt, VMT_STUB); /* mount point */ stub = vmt2dataptr(vmt, VMT_STUB); /* mount point */
if (EQ(obj, dev) || EQ(uv__rawname(obj), dev) || EQ(stub, dev)) { if (EQ(obj, dev) || EQ(uv__rawname(obj, &rawbuf), dev) || EQ(stub, dev)) {
uv__free(p); /* Found a match */ uv__free(p); /* Found a match */
return 0; return 0;
} }
@ -453,7 +450,8 @@ static int uv__makedir_p(const char *dir) {
size_t len; size_t len;
int err; int err;
snprintf(tmp, sizeof(tmp),"%s",dir); /* TODO(bnoordhuis) Check uv__strscpy() return value. */
uv__strscpy(tmp, dir, sizeof(tmp));
len = strlen(tmp); len = strlen(tmp);
if (tmp[len - 1] == '/') if (tmp[len - 1] == '/')
tmp[len - 1] = 0; tmp[len - 1] = 0;
@ -702,9 +700,9 @@ static void uv__ahafs_event(uv_loop_t* loop, uv__io_t* event_watch, unsigned int
else else
p++; p++;
} }
strncpy(fname, p, sizeof(fname) - 1);
/* Just in case */ /* TODO(bnoordhuis) Check uv__strscpy() return value. */
fname[sizeof(fname) - 1] = '\0'; uv__strscpy(fname, p, sizeof(fname));
handle->cb(handle, fname, events, 0); handle->cb(handle, fname, events, 0);
} }
@ -735,7 +733,8 @@ int uv_fs_event_start(uv_fs_event_t* handle,
/* Figure out whether filename is absolute or not */ /* Figure out whether filename is absolute or not */
if (filename[0] == '/') { if (filename[0] == '/') {
/* We have absolute pathname */ /* We have absolute pathname */
snprintf(absolute_path, sizeof(absolute_path), "%s", filename); /* TODO(bnoordhuis) Check uv__strscpy() return value. */
uv__strscpy(absolute_path, filename, sizeof(absolute_path));
} else { } else {
/* We have a relative pathname, compose the absolute pathname */ /* We have a relative pathname, compose the absolute pathname */
snprintf(cwd, sizeof(cwd), "/proc/%lu/cwd", (unsigned long) getpid()); snprintf(cwd, sizeof(cwd), "/proc/%lu/cwd", (unsigned long) getpid());
@ -986,7 +985,8 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
return UV_ENOMEM; return UV_ENOMEM;
} }
strcpy(cpu_id.name, FIRST_CPU); /* TODO(bnoordhuis) Check uv__strscpy() return value. */
uv__strscpy(cpu_id.name, FIRST_CPU, sizeof(cpu_id.name));
result = perfstat_cpu(&cpu_id, ps_cpus, sizeof(perfstat_cpu_t), ncpus); result = perfstat_cpu(&cpu_id, ps_cpus, sizeof(perfstat_cpu_t), ncpus);
if (result == -1) { if (result == -1) {
uv__free(ps_cpus); uv__free(ps_cpus);

View File

@ -192,8 +192,7 @@ void uv__set_process_title(const char* title) {
if (dynamic_pthread_setname_np != NULL) { if (dynamic_pthread_setname_np != NULL) {
char namebuf[64]; /* MAXTHREADNAMESIZE */ char namebuf[64]; /* MAXTHREADNAMESIZE */
strncpy(namebuf, title, sizeof(namebuf) - 1); uv__strscpy(namebuf, title, sizeof(namebuf));
namebuf[sizeof(namebuf) - 1] = '\0';
dynamic_pthread_setname_np(namebuf); dynamic_pthread_setname_np(namebuf);
} }
} }

42
deps/uv/src/unix/fs.c vendored
View File

@ -61,6 +61,7 @@
#if defined(__APPLE__) #if defined(__APPLE__)
# include <copyfile.h> # include <copyfile.h>
# include <sys/sysctl.h>
#elif defined(__linux__) && !defined(FICLONE) #elif defined(__linux__) && !defined(FICLONE)
# include <sys/ioctl.h> # include <sys/ioctl.h>
# define FICLONE _IOW(0x94, 9, int) # define FICLONE _IOW(0x94, 9, int)
@ -70,6 +71,10 @@
# include <utime.h> # include <utime.h>
#endif #endif
#if defined(_AIX) && _XOPEN_SOURCE <= 600
extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
#endif
#define INIT(subtype) \ #define INIT(subtype) \
do { \ do { \
if (req == NULL) \ if (req == NULL) \
@ -722,7 +727,7 @@ static ssize_t uv__fs_utime(uv_fs_t* req) {
atr.att_atimechg = 1; atr.att_atimechg = 1;
atr.att_mtime = req->mtime; atr.att_mtime = req->mtime;
atr.att_atime = req->atime; atr.att_atime = req->atime;
return __lchattr(req->path, &atr, sizeof(atr)); return __lchattr((char*) req->path, &atr, sizeof(atr));
#else #else
errno = ENOSYS; errno = ENOSYS;
return -1; return -1;
@ -793,26 +798,41 @@ done:
static ssize_t uv__fs_copyfile(uv_fs_t* req) { static ssize_t uv__fs_copyfile(uv_fs_t* req) {
#if defined(__APPLE__) && !TARGET_OS_IPHONE #if defined(__APPLE__) && !TARGET_OS_IPHONE
/* On macOS, use the native copyfile(3). */ /* On macOS, use the native copyfile(3). */
static int can_clone;
copyfile_flags_t flags; copyfile_flags_t flags;
char buf[64];
size_t len;
int major;
flags = COPYFILE_ALL; flags = COPYFILE_ALL;
if (req->flags & UV_FS_COPYFILE_EXCL) if (req->flags & UV_FS_COPYFILE_EXCL)
flags |= COPYFILE_EXCL; flags |= COPYFILE_EXCL;
#ifdef COPYFILE_CLONE /* Check OS version. Cloning is only supported on macOS >= 10.12. */
if (req->flags & UV_FS_COPYFILE_FICLONE)
flags |= COPYFILE_CLONE;
#endif
if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) { if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
#ifdef COPYFILE_CLONE_FORCE if (can_clone == 0) {
flags |= COPYFILE_CLONE_FORCE; len = sizeof(buf);
#else if (sysctlbyname("kern.osrelease", buf, &len, NULL, 0))
return UV_ENOSYS; return UV__ERR(errno);
#endif
if (1 != sscanf(buf, "%d", &major))
abort();
can_clone = -1 + 2 * (major >= 16); /* macOS >= 10.12 */
} }
if (can_clone < 0)
return UV_ENOSYS;
}
/* copyfile() simply ignores COPYFILE_CLONE if it's not supported. */
if (req->flags & UV_FS_COPYFILE_FICLONE)
flags |= 1 << 24; /* COPYFILE_CLONE */
if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE)
flags |= 1 << 25; /* COPYFILE_CLONE_FORCE */
return copyfile(req->path, req->new_path, NULL, flags); return copyfile(req->path, req->new_path, NULL, flags);
#else #else
uv_fs_t fs_req; uv_fs_t fs_req;

View File

@ -170,6 +170,7 @@ int uv__io_check_fd(uv_loop_t* loop, int fd) {
struct epoll_event e; struct epoll_event e;
int rc; int rc;
memset(&e, 0, sizeof(e));
e.events = POLLIN; e.events = POLLIN;
e.data.fd = -1; e.data.fd = -1;
@ -218,6 +219,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
return; return;
} }
memset(&e, 0, sizeof(e));
while (!QUEUE_EMPTY(&loop->watcher_queue)) { while (!QUEUE_EMPTY(&loop->watcher_queue)) {
q = QUEUE_HEAD(&loop->watcher_queue); q = QUEUE_HEAD(&loop->watcher_queue);
QUEUE_REMOVE(q); QUEUE_REMOVE(q);

View File

@ -278,6 +278,7 @@ int uv_fs_event_start(uv_fs_event_t* handle,
const char* path, const char* path,
unsigned int flags) { unsigned int flags) {
struct watcher_list* w; struct watcher_list* w;
size_t len;
int events; int events;
int err; int err;
int wd; int wd;
@ -306,12 +307,13 @@ int uv_fs_event_start(uv_fs_event_t* handle,
if (w) if (w)
goto no_insert; goto no_insert;
w = uv__malloc(sizeof(*w) + strlen(path) + 1); len = strlen(path) + 1;
w = uv__malloc(sizeof(*w) + len);
if (w == NULL) if (w == NULL)
return UV_ENOMEM; return UV_ENOMEM;
w->wd = wd; w->wd = wd;
w->path = strcpy((char*)(w + 1), path); w->path = memcpy(w + 1, path, len);
QUEUE_INIT(&w->watchers); QUEUE_INIT(&w->watchers);
w->iterating = 0; w->iterating = 0;
RB_INSERT(watcher_root, CAST(&handle->loop->inotify_watchers), w); RB_INSERT(watcher_root, CAST(&handle->loop->inotify_watchers), w);

View File

@ -87,7 +87,8 @@ int uv_exepath(char* buffer, size_t* size) {
/* Copy string from the intermediate buffer to outer one with appropriate /* Copy string from the intermediate buffer to outer one with appropriate
* length. * length.
*/ */
strlcpy(buffer, int_buf, *size); /* TODO(bnoordhuis) Check uv__strscpy() return value. */
uv__strscpy(buffer, int_buf, *size);
/* Set new size. */ /* Set new size. */
*size = strlen(buffer); *size = strlen(buffer);

View File

@ -229,15 +229,15 @@ static int getexe(const int pid, char* buf, size_t len) {
assert(((Output_buf.Output_data.offsetPath >>24) & 0xFF) == 'A'); assert(((Output_buf.Output_data.offsetPath >>24) & 0xFF) == 'A');
/* Get the offset from the lowest 3 bytes */ /* Get the offset from the lowest 3 bytes */
Output_path = (char*)(&Output_buf) + Output_path = (struct Output_path_type*) ((char*) (&Output_buf) +
(Output_buf.Output_data.offsetPath & 0x00FFFFFF); (Output_buf.Output_data.offsetPath & 0x00FFFFFF));
if (Output_path->len >= len) { if (Output_path->len >= len) {
errno = ENOBUFS; errno = ENOBUFS;
return -1; return -1;
} }
strncpy(buf, Output_path->path, len); uv__strscpy(buf, Output_path->path, len);
return 0; return 0;
} }

View File

@ -66,8 +66,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
sockfd = err; sockfd = err;
memset(&saddr, 0, sizeof saddr); memset(&saddr, 0, sizeof saddr);
strncpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path) - 1); uv__strscpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path));
saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0';
saddr.sun_family = AF_UNIX; saddr.sun_family = AF_UNIX;
if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr)) { if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr)) {
@ -186,8 +185,7 @@ void uv_pipe_connect(uv_connect_t* req,
} }
memset(&saddr, 0, sizeof saddr); memset(&saddr, 0, sizeof saddr);
strncpy(saddr.sun_path, name, sizeof(saddr.sun_path) - 1); uv__strscpy(saddr.sun_path, name, sizeof(saddr.sun_path));
saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0';
saddr.sun_family = AF_UNIX; saddr.sun_family = AF_UNIX;
do { do {

View File

@ -707,13 +707,14 @@ static int uv__set_phys_addr(uv_interface_address_t* address,
struct sockaddr_dl* sa_addr; struct sockaddr_dl* sa_addr;
int sockfd; int sockfd;
int i; size_t i;
struct arpreq arpreq; struct arpreq arpreq;
/* This appears to only work as root */ /* This appears to only work as root */
sa_addr = (struct sockaddr_dl*)(ent->ifa_addr); sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr)); memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
for (i = 0; i < sizeof(address->phys_addr); i++) { for (i = 0; i < sizeof(address->phys_addr); i++) {
/* Check that all bytes of phys_addr are zero. */
if (address->phys_addr[i] != 0) if (address->phys_addr[i] != 0)
return 0; return 0;
} }

View File

@ -162,7 +162,7 @@ static const char* uv__unknown_err_code(int err) {
#define UV_ERR_NAME_GEN_R(name, _) \ #define UV_ERR_NAME_GEN_R(name, _) \
case UV_## name: \ case UV_## name: \
snprintf(buf, buflen, "%s", #name); break; uv__strscpy(buf, #name, buflen); break;
char* uv_err_name_r(int err, char* buf, size_t buflen) { char* uv_err_name_r(int err, char* buf, size_t buflen) {
switch (err) { switch (err) {
UV_ERRNO_MAP(UV_ERR_NAME_GEN_R) UV_ERRNO_MAP(UV_ERR_NAME_GEN_R)

View File

@ -40,6 +40,7 @@
#include "uv.h" #include "uv.h"
#include "uv/tree.h" #include "uv/tree.h"
#include "queue.h" #include "queue.h"
#include "strscpy.h"
#if EDOM > 0 #if EDOM > 0
# define UV__ERR(x) (-(x)) # define UV__ERR(x) (-(x))

View File

@ -34,7 +34,9 @@ const char* uv_req_type_name(uv_req_type type) {
UV_REQ_TYPE_MAP(XX) UV_REQ_TYPE_MAP(XX)
#undef XX #undef XX
case UV_REQ_TYPE_MAX: case UV_REQ_TYPE_MAX:
case UV_UNKNOWN_REQ: return NULL; case UV_UNKNOWN_REQ:
default: /* UV_REQ_TYPE_PRIVATE */
return NULL;
} }
return NULL; return NULL;
} }

View File

@ -64,7 +64,8 @@ void uv_dlclose(uv_lib_t* lib) {
int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) { int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) {
*ptr = (void*) GetProcAddress(lib->handle, name); /* Cast though integer to suppress pedantic warning about forbidden cast. */
*ptr = (void*)(uintptr_t) GetProcAddress(lib->handle, name);
return uv__dlerror(lib, "", *ptr ? 0 : GetLastError()); return uv__dlerror(lib, "", *ptr ? 0 : GetLastError());
} }
@ -75,8 +76,9 @@ const char* uv_dlerror(const uv_lib_t* lib) {
static void uv__format_fallback_error(uv_lib_t* lib, int errorno){ static void uv__format_fallback_error(uv_lib_t* lib, int errorno){
DWORD_PTR args[1] = { (DWORD_PTR) errorno }; static const CHAR fallback_error[] = "error: %1!d!";
LPSTR fallback_error = "error: %1!d!"; DWORD_PTR args[1];
args[0] = (DWORD_PTR) errorno;
FormatMessageA(FORMAT_MESSAGE_FROM_STRING | FormatMessageA(FORMAT_MESSAGE_FROM_STRING |
FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_ARGUMENT_ARRAY |

View File

@ -215,12 +215,12 @@ int uv_fs_event_start(uv_fs_event_t* handle,
uv__free(long_path); uv__free(long_path);
long_path = NULL; long_path = NULL;
} }
}
if (long_path) { if (long_path) {
uv__free(pathw); uv__free(pathw);
pathw = long_path; pathw = long_path;
} }
}
dir_to_watch = pathw; dir_to_watch = pathw;
} else { } else {

49
deps/uv/src/win/fs.c vendored
View File

@ -98,14 +98,17 @@
return; \ return; \
} }
#define MILLIONu (1000U * 1000U)
#define BILLIONu (1000U * 1000U * 1000U)
#define FILETIME_TO_UINT(filetime) \ #define FILETIME_TO_UINT(filetime) \
(*((uint64_t*) &(filetime)) - 116444736000000000ULL) (*((uint64_t*) &(filetime)) - (uint64_t) 116444736 * BILLIONu)
#define FILETIME_TO_TIME_T(filetime) \ #define FILETIME_TO_TIME_T(filetime) \
(FILETIME_TO_UINT(filetime) / 10000000ULL) (FILETIME_TO_UINT(filetime) / (10u * MILLIONu))
#define FILETIME_TO_TIME_NS(filetime, secs) \ #define FILETIME_TO_TIME_NS(filetime, secs) \
((FILETIME_TO_UINT(filetime) - (secs * 10000000ULL)) * 100) ((FILETIME_TO_UINT(filetime) - (secs * (uint64_t) 10 * MILLIONu)) * 100U)
#define FILETIME_TO_TIMESPEC(ts, filetime) \ #define FILETIME_TO_TIMESPEC(ts, filetime) \
do { \ do { \
@ -115,8 +118,8 @@
#define TIME_T_TO_FILETIME(time, filetime_ptr) \ #define TIME_T_TO_FILETIME(time, filetime_ptr) \
do { \ do { \
uint64_t bigtime = ((uint64_t) ((time) * 10000000ULL)) + \ uint64_t bigtime = ((uint64_t) ((time) * (uint64_t) 10 * MILLIONu)) + \
116444736000000000ULL; \ (uint64_t) 116444736 * BILLIONu; \
(filetime_ptr)->dwLowDateTime = bigtime & 0xFFFFFFFF; \ (filetime_ptr)->dwLowDateTime = bigtime & 0xFFFFFFFF; \
(filetime_ptr)->dwHighDateTime = bigtime >> 32; \ (filetime_ptr)->dwHighDateTime = bigtime >> 32; \
} while(0) } while(0)
@ -507,6 +510,33 @@ void fs__open(uv_fs_t* req) {
} }
if (flags & UV_FS_O_DIRECT) { if (flags & UV_FS_O_DIRECT) {
/*
* FILE_APPEND_DATA and FILE_FLAG_NO_BUFFERING are mutually exclusive.
* Windows returns 87, ERROR_INVALID_PARAMETER if these are combined.
*
* FILE_APPEND_DATA is included in FILE_GENERIC_WRITE:
*
* FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE |
* FILE_WRITE_DATA |
* FILE_WRITE_ATTRIBUTES |
* FILE_WRITE_EA |
* FILE_APPEND_DATA |
* SYNCHRONIZE
*
* Note: Appends are also permitted by FILE_WRITE_DATA.
*
* In order for direct writes and direct appends to succeed, we therefore
* exclude FILE_APPEND_DATA if FILE_WRITE_DATA is specified, and otherwise
* fail if the user's sole permission is a direct append, since this
* particular combination is invalid.
*/
if (access & FILE_APPEND_DATA) {
if (access & FILE_WRITE_DATA) {
access &= ~FILE_APPEND_DATA;
} else {
goto einval;
}
}
attributes |= FILE_FLAG_NO_BUFFERING; attributes |= FILE_FLAG_NO_BUFFERING;
} }
@ -788,9 +818,8 @@ void fs__unlink(uv_fs_t* req) {
/* Remove read-only attribute */ /* Remove read-only attribute */
FILE_BASIC_INFORMATION basic = { 0 }; FILE_BASIC_INFORMATION basic = { 0 };
basic.FileAttributes = info.dwFileAttributes basic.FileAttributes = (info.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY) |
& ~(FILE_ATTRIBUTE_READONLY) FILE_ATTRIBUTE_ARCHIVE;
| FILE_ATTRIBUTE_ARCHIVE;
status = pNtSetInformationFile(handle, status = pNtSetInformationFile(handle,
&iosb, &iosb,
@ -1201,7 +1230,7 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf,
/* st_blocks contains the on-disk allocation size in 512-byte units. */ /* st_blocks contains the on-disk allocation size in 512-byte units. */
statbuf->st_blocks = statbuf->st_blocks =
file_info.StandardInformation.AllocationSize.QuadPart >> 9ULL; (uint64_t) file_info.StandardInformation.AllocationSize.QuadPart >> 9;
statbuf->st_nlink = file_info.StandardInformation.NumberOfLinks; statbuf->st_nlink = file_info.StandardInformation.NumberOfLinks;
@ -1958,7 +1987,7 @@ static void fs__readlink(uv_fs_t* req) {
} }
static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) {
int r; int r;
DWORD w_realpath_len; DWORD w_realpath_len;
WCHAR* w_realpath_ptr = NULL; WCHAR* w_realpath_ptr = NULL;

View File

@ -1541,7 +1541,7 @@ int uv__pipe_write_ipc(uv_loop_t* loop,
frame_header.flags |= UV__IPC_FRAME_HAS_SOCKET_XFER; frame_header.flags |= UV__IPC_FRAME_HAS_SOCKET_XFER;
break; break;
default: default:
assert(0); // Unreachable. assert(0); /* Unreachable. */
} }
/* Add xfer info buffer. */ /* Add xfer info buffer. */
bufs[buf_index++] = uv_buf_init((char*) &xfer_info, sizeof xfer_info); bufs[buf_index++] = uv_buf_init((char*) &xfer_info, sizeof xfer_info);
@ -2141,7 +2141,7 @@ int uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
if (pipe->ipc) { if (pipe->ipc) {
assert(!(pipe->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)); assert(!(pipe->flags & UV_HANDLE_NON_OVERLAPPED_PIPE));
pipe->pipe.conn.ipc_remote_pid = uv_os_getppid(); pipe->pipe.conn.ipc_remote_pid = uv_os_getppid();
assert(pipe->pipe.conn.ipc_remote_pid != -1); assert(pipe->pipe.conn.ipc_remote_pid != (DWORD) -1);
} }
return 0; return 0;
} }
@ -2312,7 +2312,7 @@ uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) {
} }
int uv_pipe_chmod(uv_pipe_t* handle, int mode) { int uv_pipe_chmod(uv_pipe_t* handle, int mode) {
SID_IDENTIFIER_AUTHORITY sid_world = SECURITY_WORLD_SID_AUTHORITY; SID_IDENTIFIER_AUTHORITY sid_world = { SECURITY_WORLD_SID_AUTHORITY };
PACL old_dacl, new_dacl; PACL old_dacl, new_dacl;
PSECURITY_DESCRIPTOR sd; PSECURITY_DESCRIPTOR sd;
EXPLICIT_ACCESS ea; EXPLICIT_ACCESS ea;

View File

@ -75,7 +75,7 @@ static AFD_POLL_INFO* uv__get_afd_poll_info_dummy(void) {
static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
uv_req_t* req; uv_req_t* req;
AFD_POLL_INFO* afd_poll_info; AFD_POLL_INFO* afd_poll_info;
DWORD result; int result;
/* Find a yet unsubmitted req to submit. */ /* Find a yet unsubmitted req to submit. */
if (handle->submitted_events_1 == 0) { if (handle->submitted_events_1 == 0) {
@ -136,7 +136,7 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
static int uv__fast_poll_cancel_poll_req(uv_loop_t* loop, uv_poll_t* handle) { static int uv__fast_poll_cancel_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
AFD_POLL_INFO afd_poll_info; AFD_POLL_INFO afd_poll_info;
DWORD result; int result;
afd_poll_info.Exclusive = TRUE; afd_poll_info.Exclusive = TRUE;
afd_poll_info.NumberOfHandles = 1; afd_poll_info.NumberOfHandles = 1;

View File

@ -739,7 +739,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
} }
} }
*ptr_copy = NULL; *ptr_copy = NULL;
assert(env_len == ptr - dst_copy); assert(env_len == (size_t) (ptr - dst_copy));
/* sort our (UTF-16) copy */ /* sort our (UTF-16) copy */
qsort(env_copy, env_block_count-1, sizeof(wchar_t*), qsort_wcscmp); qsort(env_copy, env_block_count-1, sizeof(wchar_t*), qsort_wcscmp);
@ -799,7 +799,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
var_size = GetEnvironmentVariableW(required_vars[i].wide, var_size = GetEnvironmentVariableW(required_vars[i].wide,
ptr, ptr,
(int) (env_len - (ptr - dst))); (int) (env_len - (ptr - dst)));
if (var_size != len-1) { /* race condition? */ if (var_size != (DWORD) (len - 1)) { /* TODO: handle race condition? */
uv_fatal_error(GetLastError(), "GetEnvironmentVariableW"); uv_fatal_error(GetLastError(), "GetEnvironmentVariableW");
} }
} }
@ -815,7 +815,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
} }
/* Terminate with an extra NULL. */ /* Terminate with an extra NULL. */
assert(env_len == (ptr - dst)); assert(env_len == (size_t) (ptr - dst));
*ptr = L'\0'; *ptr = L'\0';
uv__free(dst_copy); uv__free(dst_copy);

View File

@ -791,8 +791,9 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
if (KEV.uChar.UnicodeChar >= 0xDC00 && if (KEV.uChar.UnicodeChar >= 0xDC00 &&
KEV.uChar.UnicodeChar < 0xE000) { KEV.uChar.UnicodeChar < 0xE000) {
/* UTF-16 surrogate pair */ /* UTF-16 surrogate pair */
WCHAR utf16_buffer[2] = { handle->tty.rd.last_utf16_high_surrogate, WCHAR utf16_buffer[2];
KEV.uChar.UnicodeChar}; utf16_buffer[0] = handle->tty.rd.last_utf16_high_surrogate;
utf16_buffer[1] = KEV.uChar.UnicodeChar;
char_len = WideCharToMultiByte(CP_UTF8, char_len = WideCharToMultiByte(CP_UTF8,
0, 0,
utf16_buffer, utf16_buffer,

View File

@ -4109,6 +4109,9 @@
#endif #endif
/* from winternl.h */ /* from winternl.h */
#if !defined(__UNICODE_STRING_DEFINED) && defined(__MINGW32_)
#define __UNICODE_STRING_DEFINED
#endif
typedef struct _UNICODE_STRING { typedef struct _UNICODE_STRING {
USHORT Length; USHORT Length;
USHORT MaximumLength; USHORT MaximumLength;

View File

@ -142,11 +142,11 @@ static int maybe_run_test(int argc, char **argv) {
if (strcmp(argv[1], "spawn_helper5") == 0) { if (strcmp(argv[1], "spawn_helper5") == 0) {
const char out[] = "fourth stdio!\n"; const char out[] = "fourth stdio!\n";
notify_parent_process(); notify_parent_process();
{
#ifdef _WIN32 #ifdef _WIN32
DWORD bytes; DWORD bytes;
WriteFile((HANDLE) _get_osfhandle(3), out, sizeof(out) - 1, &bytes, NULL); WriteFile((HANDLE) _get_osfhandle(3), out, sizeof(out) - 1, &bytes, NULL);
#else #else
{
ssize_t r; ssize_t r;
do do
@ -154,8 +154,8 @@ static int maybe_run_test(int argc, char **argv) {
while (r == -1 && errno == EINTR); while (r == -1 && errno == EINTR);
fsync(3); fsync(3);
}
#endif #endif
}
return 1; return 1;
} }

View File

@ -194,7 +194,7 @@ int process_wait(process_info_t *vec, int n, int timeout) {
result = WaitForMultipleObjects(n, handles, TRUE, timeout_api); result = WaitForMultipleObjects(n, handles, TRUE, timeout_api);
if (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + n) { if (result < WAIT_OBJECT_0 + n) {
/* All processes are terminated. */ /* All processes are terminated. */
return 0; return 0;
} }
@ -268,7 +268,8 @@ int process_read_last_line(process_info_t *p,
if (!ReadFile(p->stdio_out, buffer, buffer_len - 1, &read, &overlapped)) if (!ReadFile(p->stdio_out, buffer, buffer_len - 1, &read, &overlapped))
return -1; return -1;
for (start = read - 1; start >= 0; start--) { start = read;
while (start-- > 0) {
if (buffer[start] == '\n' || buffer[start] == '\r') if (buffer[start] == '\n' || buffer[start] == '\r')
break; break;
} }
@ -308,7 +309,7 @@ void process_cleanup(process_info_t *p) {
} }
static int clear_line() { static int clear_line(void) {
HANDLE handle; HANDLE handle;
CONSOLE_SCREEN_BUFFER_INFO info; CONSOLE_SCREEN_BUFFER_INFO info;
COORD coord; COORD coord;

View File

@ -20,7 +20,9 @@
*/ */
/* Don't complain about write(), fileno() etc. being deprecated. */ /* Don't complain about write(), fileno() etc. being deprecated. */
#ifdef _MSC_VER
#pragma warning(disable : 4996) #pragma warning(disable : 4996)
#endif
#include <winsock2.h> #include <winsock2.h>

View File

@ -73,4 +73,8 @@ TEST_IMPL(close_fd) {
return 0; return 0;
} }
#endif /* !defined(_WIN32) */ #else
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
#endif /* !_WIN32 */

View File

@ -235,7 +235,7 @@ TEST_IMPL(condvar_5) {
uint64_t elapsed; uint64_t elapsed;
uint64_t timeout; uint64_t timeout;
timeout = 100 * 1e6; /* 100 ms in ns */ timeout = 100 * 1000 * 1000; /* 100 ms in ns */
/* Mostly irrelevant. We need cond and mutex initialized. */ /* Mostly irrelevant. We need cond and mutex initialized. */
worker_config_init(&wc, 0, NULL, NULL); worker_config_init(&wc, 0, NULL, NULL);

View File

@ -38,6 +38,11 @@ static uv_tcp_t client_handle;
TEST_IMPL(emfile) { TEST_IMPL(emfile) {
struct sockaddr_in addr;
struct rlimit limits;
uv_connect_t connect_req;
uv_loop_t* loop;
int first_fd;
#if defined(_AIX) || defined(__MVS__) #if defined(_AIX) || defined(__MVS__)
/* On AIX, if a 'accept' call fails ECONNRESET is set on the socket /* On AIX, if a 'accept' call fails ECONNRESET is set on the socket
* which causes uv__emfile_trick to not work as intended and this test * which causes uv__emfile_trick to not work as intended and this test
@ -45,11 +50,6 @@ TEST_IMPL(emfile) {
*/ */
RETURN_SKIP("uv__emfile_trick does not work on this OS"); RETURN_SKIP("uv__emfile_trick does not work on this OS");
#endif #endif
struct sockaddr_in addr;
struct rlimit limits;
uv_connect_t connect_req;
uv_loop_t* loop;
int first_fd;
/* Lower the file descriptor limit and use up all fds save one. */ /* Lower the file descriptor limit and use up all fds save one. */
limits.rlim_cur = limits.rlim_max = maxfd + 1; limits.rlim_cur = limits.rlim_max = maxfd + 1;
@ -114,4 +114,8 @@ static void connect_cb(uv_connect_t* req, int status) {
uv_close((uv_handle_t*) &client_handle, NULL); uv_close((uv_handle_t*) &client_handle, NULL);
} }
#endif /* !defined(_WIN32) */ #else
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
#endif /* !_WIN32 */

View File

@ -676,5 +676,8 @@ TEST_IMPL(fork_threadpool_queue_work_simple) {
} }
#endif /* !__MVS__ */ #endif /* !__MVS__ */
#else
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
#endif /* !_WIN32 */ #endif /* !_WIN32 */

View File

@ -154,7 +154,7 @@ int uv_test_getiovmax(void) {
static unsigned REPARSE_TAG = 0x9913; static unsigned REPARSE_TAG = 0x9913;
static GUID REPARSE_GUID = { static GUID REPARSE_GUID = {
0x1bf6205f, 0x46ae, 0x4527, 0x1bf6205f, 0x46ae, 0x4527,
0xb1, 0x0c, 0xc5, 0x09, 0xb7, 0x55, 0x22, 0x80 }; { 0xb1, 0x0c, 0xc5, 0x09, 0xb7, 0x55, 0x22, 0x80 }};
#endif #endif
static void check_permission(const char* filename, unsigned int mode) { static void check_permission(const char* filename, unsigned int mode) {
@ -2331,9 +2331,6 @@ TEST_IMPL(fs_stat_root) {
TEST_IMPL(fs_futime) { TEST_IMPL(fs_futime) {
#if defined(_AIX) && !defined(_AIX71)
RETURN_SKIP("futime is not implemented for AIX versions below 7.1");
#else
utime_check_t checkme; utime_check_t checkme;
const char* path = "test_file"; const char* path = "test_file";
double atime; double atime;
@ -2341,6 +2338,9 @@ TEST_IMPL(fs_futime) {
uv_file file; uv_file file;
uv_fs_t req; uv_fs_t req;
int r; int r;
#if defined(_AIX) && !defined(_AIX71)
RETURN_SKIP("futime is not implemented for AIX versions below 7.1");
#endif
/* Setup. */ /* Setup. */
loop = uv_default_loop(); loop = uv_default_loop();
@ -2402,7 +2402,6 @@ TEST_IMPL(fs_futime) {
MAKE_VALGRIND_HAPPY(); MAKE_VALGRIND_HAPPY();
return 0; return 0;
#endif
} }
@ -3601,6 +3600,53 @@ TEST_IMPL(fs_exclusive_sharing_mode) {
} }
#endif #endif
#ifdef _WIN32
TEST_IMPL(fs_file_flag_no_buffering) {
int r;
/* Setup. */
unlink("test_file");
ASSERT(UV_FS_O_APPEND > 0);
ASSERT(UV_FS_O_CREAT > 0);
ASSERT(UV_FS_O_DIRECT > 0);
ASSERT(UV_FS_O_RDWR > 0);
/* FILE_APPEND_DATA must be excluded from FILE_GENERIC_WRITE: */
r = uv_fs_open(NULL,
&open_req1,
"test_file",
UV_FS_O_RDWR | UV_FS_O_CREAT | UV_FS_O_DIRECT,
S_IWUSR | S_IRUSR,
NULL);
ASSERT(r >= 0);
ASSERT(open_req1.result >= 0);
uv_fs_req_cleanup(&open_req1);
r = uv_fs_close(NULL, &close_req, open_req1.result, NULL);
ASSERT(r == 0);
ASSERT(close_req.result == 0);
uv_fs_req_cleanup(&close_req);
/* FILE_APPEND_DATA and FILE_FLAG_NO_BUFFERING are mutually exclusive: */
r = uv_fs_open(NULL,
&open_req2,
"test_file",
UV_FS_O_APPEND | UV_FS_O_DIRECT,
S_IWUSR | S_IRUSR,
NULL);
ASSERT(r == UV_EINVAL);
ASSERT(open_req2.result == UV_EINVAL);
uv_fs_req_cleanup(&open_req2);
/* Cleanup */
unlink("test_file");
MAKE_VALGRIND_HAPPY();
return 0;
}
#endif
#ifdef _WIN32 #ifdef _WIN32
int call_icacls(const char* command, ...) { int call_icacls(const char* command, ...) {
char icacls_command[1024]; char icacls_command[1024];

View File

@ -27,8 +27,13 @@
TEST_IMPL(ip4_addr) { TEST_IMPL(ip4_addr) {
struct sockaddr_in addr; struct sockaddr_in addr;
char dst[16];
ASSERT(0 == uv_inet_ntop(AF_INET, "\xFF\xFF\xFF\xFF", dst, sizeof(dst)));
ASSERT(0 == strcmp(dst, "255.255.255.255"));
ASSERT(UV_ENOSPC == uv_inet_ntop(AF_INET, "\xFF\xFF\xFF\xFF",
dst, sizeof(dst) - 1));
ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
ASSERT(0 == uv_ip4_addr("255.255.255.255", TEST_PORT, &addr)); ASSERT(0 == uv_ip4_addr("255.255.255.255", TEST_PORT, &addr));

View File

@ -83,7 +83,7 @@ TEST_IMPL(ip6_addr_link_local) {
ASSERT(0 == r); ASSERT(0 == r);
#ifdef _WIN32 #ifdef _WIN32
/* On Windows, the interface identifier is the numeric string of the index. */ /* On Windows, the interface identifier is the numeric string of the index. */
ASSERT(strtol(interface_id, NULL, 10) == iface_index); ASSERT(strtoul(interface_id, NULL, 10) == iface_index);
#else #else
/* On Unix/Linux, the interface identifier is the interface device name. */ /* On Unix/Linux, the interface identifier is the interface device name. */
ASSERT(0 == strcmp(device_name, interface_id)); ASSERT(0 == strcmp(device_name, interface_id));

View File

@ -349,9 +349,11 @@ TEST_DECLARE (fs_null_req)
TEST_DECLARE (fs_read_dir) TEST_DECLARE (fs_read_dir)
#ifdef _WIN32 #ifdef _WIN32
TEST_DECLARE (fs_exclusive_sharing_mode) TEST_DECLARE (fs_exclusive_sharing_mode)
TEST_DECLARE (fs_file_flag_no_buffering)
TEST_DECLARE (fs_open_readonly_acl) TEST_DECLARE (fs_open_readonly_acl)
TEST_DECLARE (fs_fchmod_archive_readonly) TEST_DECLARE (fs_fchmod_archive_readonly)
#endif #endif
TEST_DECLARE (strscpy)
TEST_DECLARE (threadpool_queue_work_simple) TEST_DECLARE (threadpool_queue_work_simple)
TEST_DECLARE (threadpool_queue_work_einval) TEST_DECLARE (threadpool_queue_work_einval)
TEST_DECLARE (threadpool_multiple_event_loops) TEST_DECLARE (threadpool_multiple_event_loops)
@ -904,11 +906,13 @@ TASK_LIST_START
TEST_ENTRY (fs_read_dir) TEST_ENTRY (fs_read_dir)
#ifdef _WIN32 #ifdef _WIN32
TEST_ENTRY (fs_exclusive_sharing_mode) TEST_ENTRY (fs_exclusive_sharing_mode)
TEST_ENTRY (fs_file_flag_no_buffering)
TEST_ENTRY (fs_open_readonly_acl) TEST_ENTRY (fs_open_readonly_acl)
TEST_ENTRY (fs_fchmod_archive_readonly) TEST_ENTRY (fs_fchmod_archive_readonly)
#endif #endif
TEST_ENTRY (get_osfhandle_valid_handle) TEST_ENTRY (get_osfhandle_valid_handle)
TEST_ENTRY (open_osfhandle_valid_handle) TEST_ENTRY (open_osfhandle_valid_handle)
TEST_ENTRY (strscpy)
TEST_ENTRY (threadpool_queue_work_simple) TEST_ENTRY (threadpool_queue_work_simple)
TEST_ENTRY (threadpool_queue_work_einval) TEST_ENTRY (threadpool_queue_work_einval)
TEST_ENTRY (threadpool_multiple_event_loops) TEST_ENTRY (threadpool_multiple_event_loops)

View File

@ -105,4 +105,8 @@ TEST_IMPL(pipe_close_stdout_read_stdin) {
return 0; return 0;
} }
#else
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
#endif /* ifndef _WIN32 */ #endif /* ifndef _WIN32 */

View File

@ -49,7 +49,7 @@ TEST_IMPL(platform_output) {
printf("uv_cwd: %s\n", buffer); printf("uv_cwd: %s\n", buffer);
err = uv_resident_set_memory(&rss); err = uv_resident_set_memory(&rss);
#if defined(__CYGWIN__) || defined(__MSYS__) #if defined(__MSYS__)
ASSERT(err == UV_ENOSYS); ASSERT(err == UV_ENOSYS);
#else #else
ASSERT(err == 0); ASSERT(err == 0);

View File

@ -49,7 +49,7 @@ static void poll_cb(uv_poll_t* h, int status, int events) {
} }
static void NO_INLINE close_socket_and_verify_stack() { static void NO_INLINE close_socket_and_verify_stack(void) {
const uint32_t MARKER = 0xDEADBEEF; const uint32_t MARKER = 0xDEADBEEF;
const int VERIFY_AFTER = 10; /* ms */ const int VERIFY_AFTER = 10; /* ms */
int r; int r;

View File

@ -202,4 +202,9 @@ TEST_IMPL(poll_oob) {
MAKE_VALGRIND_HAPPY(); MAKE_VALGRIND_HAPPY();
return 0; return 0;
} }
#else
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
#endif #endif

View File

@ -70,7 +70,7 @@ TEST_IMPL(process_title_threadsafe) {
#if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__) || \ #if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__) || \
defined(__MVS__) defined(__MVS__)
RETURN_SKIP("uv_(get|set)_process_title is not implemented."); RETURN_SKIP("uv_(get|set)_process_title is not implemented.");
#else #endif
ASSERT(0 == uv_set_process_title(titles[0])); ASSERT(0 == uv_set_process_title(titles[0]));
ASSERT(0 == uv_thread_create(&getter_thread, getter_thread_body, NULL)); ASSERT(0 == uv_thread_create(&getter_thread, getter_thread_body, NULL));
@ -82,5 +82,4 @@ TEST_IMPL(process_title_threadsafe) {
ASSERT(0 == uv_thread_join(&setter_threads[i])); ASSERT(0 == uv_thread_join(&setter_threads[i]));
return 0; return 0;
#endif
} }

View File

@ -62,7 +62,8 @@ static void uv_get_process_title_edge_cases(void) {
TEST_IMPL(process_title) { TEST_IMPL(process_title) {
#if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__) #if defined(__sun) || defined(__CYGWIN__) || defined(__MSYS__)
RETURN_SKIP("uv_(get|set)_process_title is not implemented."); RETURN_SKIP("uv_(get|set)_process_title is not implemented.");
#else #endif
/* Check for format string vulnerabilities. */ /* Check for format string vulnerabilities. */
set_title("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"); set_title("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s");
set_title("new title"); set_title("new title");
@ -71,5 +72,4 @@ TEST_IMPL(process_title) {
uv_get_process_title_edge_cases(); uv_get_process_title_edge_cases();
return 0; return 0;
#endif
} }

View File

@ -295,4 +295,8 @@ TEST_IMPL(signal_multiple_loops) {
return 0; return 0;
} }
#else
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
#endif /* !_WIN32 */ #endif /* !_WIN32 */

View File

@ -49,7 +49,9 @@ static char exepath[1024];
static size_t exepath_size = 1024; static size_t exepath_size = 1024;
static char* args[5]; static char* args[5];
static int no_term_signal; static int no_term_signal;
#ifndef _WIN32
static int timer_counter; static int timer_counter;
#endif
static uv_tcp_t tcp_server; static uv_tcp_t tcp_server;
#define OUTPUT_SIZE 1024 #define OUTPUT_SIZE 1024
@ -138,10 +140,12 @@ static void on_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) {
} }
#ifndef _WIN32
static void on_read_once(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { static void on_read_once(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) {
uv_read_stop(tcp); uv_read_stop(tcp);
on_read(tcp, nread, buf); on_read(tcp, nread, buf);
} }
#endif
static void write_cb(uv_write_t* req, int status) { static void write_cb(uv_write_t* req, int status) {
@ -173,9 +177,11 @@ static void timer_cb(uv_timer_t* handle) {
} }
#ifndef _WIN32
static void timer_counter_cb(uv_timer_t* handle) { static void timer_counter_cb(uv_timer_t* handle) {
++timer_counter; ++timer_counter;
} }
#endif
TEST_IMPL(spawn_fails) { TEST_IMPL(spawn_fails) {
@ -1198,7 +1204,7 @@ TEST_IMPL(argument_escaping) {
int make_program_env(char** env_block, WCHAR** dst_ptr); int make_program_env(char** env_block, WCHAR** dst_ptr);
TEST_IMPL(environment_creation) { TEST_IMPL(environment_creation) {
int i; size_t i;
char* environment[] = { char* environment[] = {
"FOO=BAR", "FOO=BAR",
"SYSTEM=ROOT", /* substring of a supplied var name */ "SYSTEM=ROOT", /* substring of a supplied var name */

53
deps/uv/test/test-strscpy.c vendored Normal file
View File

@ -0,0 +1,53 @@
/* Copyright libuv project contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include "uv.h"
#include "task.h"
#include <string.h>
#include "../src/strscpy.h"
#include "../src/strscpy.c"
TEST_IMPL(strscpy) {
char d[4];
ASSERT(0 == uv__strscpy(d, "", 0));
ASSERT(0 == uv__strscpy(d, "x", 0));
memset(d, 0, sizeof(d));
ASSERT(1 == uv__strscpy(d, "x", sizeof(d)));
ASSERT(0 == memcmp(d, "x\0\0", sizeof(d)));
memset(d, 0, sizeof(d));
ASSERT(2 == uv__strscpy(d, "xy", sizeof(d)));
ASSERT(0 == memcmp(d, "xy\0", sizeof(d)));
ASSERT(3 == uv__strscpy(d, "xyz", sizeof(d)));
ASSERT(0 == memcmp(d, "xyz", sizeof(d)));
ASSERT(UV_E2BIG == uv__strscpy(d, "xyzz", sizeof(d)));
ASSERT(0 == memcmp(d, "xyz", sizeof(d)));
ASSERT(UV_E2BIG == uv__strscpy(d, "xyzzy", sizeof(d)));
ASSERT(0 == memcmp(d, "xyz", sizeof(d)));
return 0;
}

View File

@ -191,4 +191,8 @@ TEST_IMPL(tcp_close_accept) {
return 0; return 0;
} }
#else
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
#endif /* !_WIN32 */ #endif /* !_WIN32 */

View File

@ -138,4 +138,9 @@ TEST_IMPL(tcp_oob) {
MAKE_VALGRIND_HAPPY(); MAKE_VALGRIND_HAPPY();
return 0; return 0;
} }
#endif
#else
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
#endif /* !_WIN32 */

View File

@ -65,4 +65,8 @@ TEST_IMPL(tcp_write_after_connect) {
return 0; return 0;
} }
#endif #else
typedef int file_has_no_tests; /* ISO C forbids an empty translation unit. */
#endif /* !_WIN32 */

View File

@ -315,10 +315,8 @@ TEST_IMPL(tty_raw_cancel) {
int r; int r;
int ttyin_fd; int ttyin_fd;
uv_tty_t tty_in; uv_tty_t tty_in;
uv_loop_t* loop;
HANDLE handle; HANDLE handle;
loop = uv_default_loop();
/* Make sure we have an FD that refers to a tty */ /* Make sure we have an FD that refers to a tty */
handle = CreateFileA("conin$", handle = CreateFileA("conin$",
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,

View File

@ -34,6 +34,7 @@
'test-fs.c', 'test-fs.c',
'test-fs-copyfile.c', 'test-fs-copyfile.c',
'test-fs-event.c', 'test-fs-event.c',
'test-fs-poll.c',
'test-getters-setters.c', 'test-getters-setters.c',
'test-get-currentexe.c', 'test-get-currentexe.c',
'test-get-memory.c', 'test-get-memory.c',
@ -96,7 +97,7 @@
'test-signal-multiple-loops.c', 'test-signal-multiple-loops.c',
'test-socket-buffer-size.c', 'test-socket-buffer-size.c',
'test-spawn.c', 'test-spawn.c',
'test-fs-poll.c', 'test-strscpy.c',
'test-stdio-over-pipes.c', 'test-stdio-over-pipes.c',
'test-tcp-alloc-cb-fail.c', 'test-tcp-alloc-cb-fail.c',
'test-tcp-bind-error.c', 'test-tcp-bind-error.c',

2
deps/uv/uv.gyp vendored
View File

@ -74,6 +74,8 @@
'src/idna.h', 'src/idna.h',
'src/inet.c', 'src/inet.c',
'src/queue.h', 'src/queue.h',
'src/strscpy.c',
'src/strscpy.h',
'src/threadpool.c', 'src/threadpool.c',
'src/timer.c', 'src/timer.c',
'src/uv-data-getter-setters.c', 'src/uv-data-getter-setters.c',