summaryrefslogtreecommitdiff
path: root/deps/uv/src
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/src')
-rw-r--r--deps/uv/src/inet.c11
-rw-r--r--deps/uv/src/strscpy.c17
-rw-r--r--deps/uv/src/strscpy.h18
-rw-r--r--deps/uv/src/timer.c2
-rw-r--r--deps/uv/src/unix/aix.c32
-rw-r--r--deps/uv/src/unix/darwin-proctitle.c3
-rw-r--r--deps/uv/src/unix/fs.c42
-rw-r--r--deps/uv/src/unix/linux-core.c3
-rw-r--r--deps/uv/src/unix/linux-inotify.c6
-rw-r--r--deps/uv/src/unix/netbsd.c3
-rw-r--r--deps/uv/src/unix/os390.c6
-rw-r--r--deps/uv/src/unix/pipe.c6
-rw-r--r--deps/uv/src/unix/sunos.c3
-rw-r--r--deps/uv/src/uv-common.c2
-rw-r--r--deps/uv/src/uv-common.h1
-rw-r--r--deps/uv/src/uv-data-getter-setters.c16
-rw-r--r--deps/uv/src/win/dl.c8
-rw-r--r--deps/uv/src/win/fs-event.c8
-rw-r--r--deps/uv/src/win/fs.c49
-rw-r--r--deps/uv/src/win/pipe.c6
-rw-r--r--deps/uv/src/win/poll.c4
-rw-r--r--deps/uv/src/win/process.c6
-rw-r--r--deps/uv/src/win/tty.c5
-rw-r--r--deps/uv/src/win/winapi.h3
24 files changed, 175 insertions, 85 deletions
diff --git a/deps/uv/src/inet.c b/deps/uv/src/inet.c
index 4598ca1e9f..698ab232e5 100644
--- a/deps/uv/src/inet.c
+++ b/deps/uv/src/inet.c
@@ -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;
}
diff --git a/deps/uv/src/strscpy.c b/deps/uv/src/strscpy.c
new file mode 100644
index 0000000000..2a2bdce745
--- /dev/null
+++ b/deps/uv/src/strscpy.c
@@ -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;
+}
diff --git a/deps/uv/src/strscpy.h b/deps/uv/src/strscpy.h
new file mode 100644
index 0000000000..fbe0a393f2
--- /dev/null
+++ b/deps/uv/src/strscpy.h
@@ -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_ */
diff --git a/deps/uv/src/timer.c b/deps/uv/src/timer.c
index 2bf449a736..dd78bcbad9 100644
--- a/deps/uv/src/timer.c
+++ b/deps/uv/src/timer.c
@@ -152,7 +152,7 @@ int uv__next_timeout(const uv_loop_t* loop) {
if (diff > INT_MAX)
diff = INT_MAX;
- return diff;
+ return (int) diff;
}
diff --git a/deps/uv/src/unix/aix.c b/deps/uv/src/unix/aix.c
index baac8e6c00..44c9cf5b63 100644
--- a/deps/uv/src/unix/aix.c
+++ b/deps/uv/src/unix/aix.c
@@ -358,19 +358,15 @@ void uv_loadavg(double avg[3]) {
#ifdef HAVE_SYS_AHAFS_EVPRODS_H
-static char *uv__rawname(char *cp) {
- static char rawbuf[FILENAME_MAX+1];
- char *dp = rindex(cp, '/');
+static char* uv__rawname(const char* cp, char (*dst)[FILENAME_MAX+1]) {
+ char* dp;
+ dp = rindex(cp, '/');
if (dp == 0)
return 0;
- *dp = 0;
- strcpy(rawbuf, cp);
- *dp = '/';
- strcat(rawbuf, "/r");
- strcat(rawbuf, dp+1);
- return rawbuf;
+ snprintf(*dst, sizeof(*dst), "%.*s/r%s", (int) (dp - cp), cp, dp + 1);
+ return *dst;
}
@@ -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
*/
static int uv__is_ahafs_mounted(void){
+ char rawbuf[FILENAME_MAX+1];
int rv, i = 2;
struct vmount *p;
int size_multiplier = 10;
@@ -432,7 +429,7 @@ static int uv__is_ahafs_mounted(void){
obj = vmt2dataptr(vmt, VMT_OBJECT); /* device */
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 */
return 0;
}
@@ -453,7 +450,8 @@ static int uv__makedir_p(const char *dir) {
size_t len;
int err;
- snprintf(tmp, sizeof(tmp),"%s",dir);
+ /* TODO(bnoordhuis) Check uv__strscpy() return value. */
+ uv__strscpy(tmp, dir, sizeof(tmp));
len = strlen(tmp);
if (tmp[len - 1] == '/')
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
p++;
}
- strncpy(fname, p, sizeof(fname) - 1);
- /* Just in case */
- fname[sizeof(fname) - 1] = '\0';
+
+ /* TODO(bnoordhuis) Check uv__strscpy() return value. */
+ uv__strscpy(fname, p, sizeof(fname));
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 */
if (filename[0] == '/') {
/* 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 {
/* We have a relative pathname, compose the absolute pathname */
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;
}
- 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);
if (result == -1) {
uv__free(ps_cpus);
diff --git a/deps/uv/src/unix/darwin-proctitle.c b/deps/uv/src/unix/darwin-proctitle.c
index 92d46b7466..e505bdd23f 100644
--- a/deps/uv/src/unix/darwin-proctitle.c
+++ b/deps/uv/src/unix/darwin-proctitle.c
@@ -192,8 +192,7 @@ void uv__set_process_title(const char* title) {
if (dynamic_pthread_setname_np != NULL) {
char namebuf[64]; /* MAXTHREADNAMESIZE */
- strncpy(namebuf, title, sizeof(namebuf) - 1);
- namebuf[sizeof(namebuf) - 1] = '\0';
+ uv__strscpy(namebuf, title, sizeof(namebuf));
dynamic_pthread_setname_np(namebuf);
}
}
diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c
index 9068d4b115..d22c70f0c2 100644
--- a/deps/uv/src/unix/fs.c
+++ b/deps/uv/src/unix/fs.c
@@ -61,6 +61,7 @@
#if defined(__APPLE__)
# include <copyfile.h>
+# include <sys/sysctl.h>
#elif defined(__linux__) && !defined(FICLONE)
# include <sys/ioctl.h>
# define FICLONE _IOW(0x94, 9, int)
@@ -70,6 +71,10 @@
# include <utime.h>
#endif
+#if defined(_AIX) && _XOPEN_SOURCE <= 600
+extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
+#endif
+
#define INIT(subtype) \
do { \
if (req == NULL) \
@@ -722,7 +727,7 @@ static ssize_t uv__fs_utime(uv_fs_t* req) {
atr.att_atimechg = 1;
atr.att_mtime = req->mtime;
atr.att_atime = req->atime;
- return __lchattr(req->path, &atr, sizeof(atr));
+ return __lchattr((char*) req->path, &atr, sizeof(atr));
#else
errno = ENOSYS;
return -1;
@@ -793,26 +798,41 @@ done:
static ssize_t uv__fs_copyfile(uv_fs_t* req) {
#if defined(__APPLE__) && !TARGET_OS_IPHONE
/* On macOS, use the native copyfile(3). */
+ static int can_clone;
copyfile_flags_t flags;
+ char buf[64];
+ size_t len;
+ int major;
flags = COPYFILE_ALL;
if (req->flags & UV_FS_COPYFILE_EXCL)
flags |= COPYFILE_EXCL;
-#ifdef COPYFILE_CLONE
- if (req->flags & UV_FS_COPYFILE_FICLONE)
- flags |= COPYFILE_CLONE;
-#endif
-
+ /* Check OS version. Cloning is only supported on macOS >= 10.12. */
if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
-#ifdef COPYFILE_CLONE_FORCE
- flags |= COPYFILE_CLONE_FORCE;
-#else
- return UV_ENOSYS;
-#endif
+ if (can_clone == 0) {
+ len = sizeof(buf);
+ if (sysctlbyname("kern.osrelease", buf, &len, NULL, 0))
+ return UV__ERR(errno);
+
+ 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);
#else
uv_fs_t fs_req;
diff --git a/deps/uv/src/unix/linux-core.c b/deps/uv/src/unix/linux-core.c
index 991d1c60ae..3341b94e1f 100644
--- a/deps/uv/src/unix/linux-core.c
+++ b/deps/uv/src/unix/linux-core.c
@@ -170,6 +170,7 @@ int uv__io_check_fd(uv_loop_t* loop, int fd) {
struct epoll_event e;
int rc;
+ memset(&e, 0, sizeof(e));
e.events = POLLIN;
e.data.fd = -1;
@@ -218,6 +219,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
return;
}
+ memset(&e, 0, sizeof(e));
+
while (!QUEUE_EMPTY(&loop->watcher_queue)) {
q = QUEUE_HEAD(&loop->watcher_queue);
QUEUE_REMOVE(q);
diff --git a/deps/uv/src/unix/linux-inotify.c b/deps/uv/src/unix/linux-inotify.c
index 7797f84252..9b26202fb3 100644
--- a/deps/uv/src/unix/linux-inotify.c
+++ b/deps/uv/src/unix/linux-inotify.c
@@ -278,6 +278,7 @@ int uv_fs_event_start(uv_fs_event_t* handle,
const char* path,
unsigned int flags) {
struct watcher_list* w;
+ size_t len;
int events;
int err;
int wd;
@@ -306,12 +307,13 @@ int uv_fs_event_start(uv_fs_event_t* handle,
if (w)
goto no_insert;
- w = uv__malloc(sizeof(*w) + strlen(path) + 1);
+ len = strlen(path) + 1;
+ w = uv__malloc(sizeof(*w) + len);
if (w == NULL)
return UV_ENOMEM;
w->wd = wd;
- w->path = strcpy((char*)(w + 1), path);
+ w->path = memcpy(w + 1, path, len);
QUEUE_INIT(&w->watchers);
w->iterating = 0;
RB_INSERT(watcher_root, CAST(&handle->loop->inotify_watchers), w);
diff --git a/deps/uv/src/unix/netbsd.c b/deps/uv/src/unix/netbsd.c
index 4cfde1a586..a2a4e52154 100644
--- a/deps/uv/src/unix/netbsd.c
+++ b/deps/uv/src/unix/netbsd.c
@@ -87,7 +87,8 @@ int uv_exepath(char* buffer, size_t* size) {
/* Copy string from the intermediate buffer to outer one with appropriate
* length.
*/
- strlcpy(buffer, int_buf, *size);
+ /* TODO(bnoordhuis) Check uv__strscpy() return value. */
+ uv__strscpy(buffer, int_buf, *size);
/* Set new size. */
*size = strlen(buffer);
diff --git a/deps/uv/src/unix/os390.c b/deps/uv/src/unix/os390.c
index b43aebfc92..dc146e3110 100644
--- a/deps/uv/src/unix/os390.c
+++ b/deps/uv/src/unix/os390.c
@@ -229,15 +229,15 @@ static int getexe(const int pid, char* buf, size_t len) {
assert(((Output_buf.Output_data.offsetPath >>24) & 0xFF) == 'A');
/* Get the offset from the lowest 3 bytes */
- Output_path = (char*)(&Output_buf) +
- (Output_buf.Output_data.offsetPath & 0x00FFFFFF);
+ Output_path = (struct Output_path_type*) ((char*) (&Output_buf) +
+ (Output_buf.Output_data.offsetPath & 0x00FFFFFF));
if (Output_path->len >= len) {
errno = ENOBUFS;
return -1;
}
- strncpy(buf, Output_path->path, len);
+ uv__strscpy(buf, Output_path->path, len);
return 0;
}
diff --git a/deps/uv/src/unix/pipe.c b/deps/uv/src/unix/pipe.c
index e450a30e9c..d3b554cfc3 100644
--- a/deps/uv/src/unix/pipe.c
+++ b/deps/uv/src/unix/pipe.c
@@ -66,8 +66,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
sockfd = err;
memset(&saddr, 0, sizeof saddr);
- strncpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path) - 1);
- saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0';
+ uv__strscpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path));
saddr.sun_family = AF_UNIX;
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);
- strncpy(saddr.sun_path, name, sizeof(saddr.sun_path) - 1);
- saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0';
+ uv__strscpy(saddr.sun_path, name, sizeof(saddr.sun_path));
saddr.sun_family = AF_UNIX;
do {
diff --git a/deps/uv/src/unix/sunos.c b/deps/uv/src/unix/sunos.c
index ec5ecd7d3c..2552a019eb 100644
--- a/deps/uv/src/unix/sunos.c
+++ b/deps/uv/src/unix/sunos.c
@@ -707,13 +707,14 @@ static int uv__set_phys_addr(uv_interface_address_t* address,
struct sockaddr_dl* sa_addr;
int sockfd;
- int i;
+ size_t i;
struct arpreq arpreq;
/* This appears to only work as root */
sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
for (i = 0; i < sizeof(address->phys_addr); i++) {
+ /* Check that all bytes of phys_addr are zero. */
if (address->phys_addr[i] != 0)
return 0;
}
diff --git a/deps/uv/src/uv-common.c b/deps/uv/src/uv-common.c
index 71d100a162..952bde080c 100644
--- a/deps/uv/src/uv-common.c
+++ b/deps/uv/src/uv-common.c
@@ -162,7 +162,7 @@ static const char* uv__unknown_err_code(int err) {
#define UV_ERR_NAME_GEN_R(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) {
switch (err) {
UV_ERRNO_MAP(UV_ERR_NAME_GEN_R)
diff --git a/deps/uv/src/uv-common.h b/deps/uv/src/uv-common.h
index 5555f83aee..15ac4d02c1 100644
--- a/deps/uv/src/uv-common.h
+++ b/deps/uv/src/uv-common.h
@@ -40,6 +40,7 @@
#include "uv.h"
#include "uv/tree.h"
#include "queue.h"
+#include "strscpy.h"
#if EDOM > 0
# define UV__ERR(x) (-(x))
diff --git a/deps/uv/src/uv-data-getter-setters.c b/deps/uv/src/uv-data-getter-setters.c
index 533e4a2fe1..b7fcd4a7fd 100644
--- a/deps/uv/src/uv-data-getter-setters.c
+++ b/deps/uv/src/uv-data-getter-setters.c
@@ -3,11 +3,11 @@
const char* uv_handle_type_name(uv_handle_type type) {
switch (type) {
#define XX(uc,lc) case UV_##uc: return #lc;
- UV_HANDLE_TYPE_MAP(XX)
+ UV_HANDLE_TYPE_MAP(XX)
#undef XX
- case UV_FILE: return "file";
- case UV_HANDLE_TYPE_MAX:
- case UV_UNKNOWN_HANDLE: return NULL;
+ case UV_FILE: return "file";
+ case UV_HANDLE_TYPE_MAX:
+ case UV_UNKNOWN_HANDLE: return NULL;
}
return NULL;
}
@@ -31,10 +31,12 @@ void uv_handle_set_data(uv_handle_t* handle, void* data) {
const char* uv_req_type_name(uv_req_type type) {
switch (type) {
#define XX(uc,lc) case UV_##uc: return #lc;
- UV_REQ_TYPE_MAP(XX)
+ UV_REQ_TYPE_MAP(XX)
#undef XX
- case UV_REQ_TYPE_MAX:
- case UV_UNKNOWN_REQ: return NULL;
+ case UV_REQ_TYPE_MAX:
+ case UV_UNKNOWN_REQ:
+ default: /* UV_REQ_TYPE_PRIVATE */
+ return NULL;
}
return NULL;
}
diff --git a/deps/uv/src/win/dl.c b/deps/uv/src/win/dl.c
index 5b84555ca4..676be4dc7b 100644
--- a/deps/uv/src/win/dl.c
+++ b/deps/uv/src/win/dl.c
@@ -64,7 +64,8 @@ void uv_dlclose(uv_lib_t* lib) {
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());
}
@@ -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){
- DWORD_PTR args[1] = { (DWORD_PTR) errorno };
- LPSTR fallback_error = "error: %1!d!";
+ static const CHAR fallback_error[] = "error: %1!d!";
+ DWORD_PTR args[1];
+ args[0] = (DWORD_PTR) errorno;
FormatMessageA(FORMAT_MESSAGE_FROM_STRING |
FORMAT_MESSAGE_ARGUMENT_ARRAY |
diff --git a/deps/uv/src/win/fs-event.c b/deps/uv/src/win/fs-event.c
index 25809ea4f2..1244967a78 100644
--- a/deps/uv/src/win/fs-event.c
+++ b/deps/uv/src/win/fs-event.c
@@ -215,11 +215,11 @@ int uv_fs_event_start(uv_fs_event_t* handle,
uv__free(long_path);
long_path = NULL;
}
- }
- if (long_path) {
- uv__free(pathw);
- pathw = long_path;
+ if (long_path) {
+ uv__free(pathw);
+ pathw = long_path;
+ }
}
dir_to_watch = pathw;
diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c
index 7ad0d077a6..0716ecca12 100644
--- a/deps/uv/src/win/fs.c
+++ b/deps/uv/src/win/fs.c
@@ -98,14 +98,17 @@
return; \
}
+#define MILLIONu (1000U * 1000U)
+#define BILLIONu (1000U * 1000U * 1000U)
+
#define FILETIME_TO_UINT(filetime) \
- (*((uint64_t*) &(filetime)) - 116444736000000000ULL)
+ (*((uint64_t*) &(filetime)) - (uint64_t) 116444736 * BILLIONu)
#define FILETIME_TO_TIME_T(filetime) \
- (FILETIME_TO_UINT(filetime) / 10000000ULL)
+ (FILETIME_TO_UINT(filetime) / (10u * MILLIONu))
#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) \
do { \
@@ -115,8 +118,8 @@
#define TIME_T_TO_FILETIME(time, filetime_ptr) \
do { \
- uint64_t bigtime = ((uint64_t) ((time) * 10000000ULL)) + \
- 116444736000000000ULL; \
+ uint64_t bigtime = ((uint64_t) ((time) * (uint64_t) 10 * MILLIONu)) + \
+ (uint64_t) 116444736 * BILLIONu; \
(filetime_ptr)->dwLowDateTime = bigtime & 0xFFFFFFFF; \
(filetime_ptr)->dwHighDateTime = bigtime >> 32; \
} while(0)
@@ -507,6 +510,33 @@ void fs__open(uv_fs_t* req) {
}
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;
}
@@ -788,9 +818,8 @@ void fs__unlink(uv_fs_t* req) {
/* Remove read-only attribute */
FILE_BASIC_INFORMATION basic = { 0 };
- basic.FileAttributes = info.dwFileAttributes
- & ~(FILE_ATTRIBUTE_READONLY)
- | FILE_ATTRIBUTE_ARCHIVE;
+ basic.FileAttributes = (info.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY) |
+ FILE_ATTRIBUTE_ARCHIVE;
status = pNtSetInformationFile(handle,
&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. */
statbuf->st_blocks =
- file_info.StandardInformation.AllocationSize.QuadPart >> 9ULL;
+ (uint64_t) file_info.StandardInformation.AllocationSize.QuadPart >> 9;
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;
DWORD w_realpath_len;
WCHAR* w_realpath_ptr = NULL;
diff --git a/deps/uv/src/win/pipe.c b/deps/uv/src/win/pipe.c
index 9a3cbc8a1e..e303cc8a23 100644
--- a/deps/uv/src/win/pipe.c
+++ b/deps/uv/src/win/pipe.c
@@ -1541,7 +1541,7 @@ int uv__pipe_write_ipc(uv_loop_t* loop,
frame_header.flags |= UV__IPC_FRAME_HAS_SOCKET_XFER;
break;
default:
- assert(0); // Unreachable.
+ assert(0); /* Unreachable. */
}
/* Add xfer info buffer. */
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) {
assert(!(pipe->flags & UV_HANDLE_NON_OVERLAPPED_PIPE));
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;
}
@@ -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) {
- SID_IDENTIFIER_AUTHORITY sid_world = SECURITY_WORLD_SID_AUTHORITY;
+ SID_IDENTIFIER_AUTHORITY sid_world = { SECURITY_WORLD_SID_AUTHORITY };
PACL old_dacl, new_dacl;
PSECURITY_DESCRIPTOR sd;
EXPLICIT_ACCESS ea;
diff --git a/deps/uv/src/win/poll.c b/deps/uv/src/win/poll.c
index 77eb071c85..3c6678600e 100644
--- a/deps/uv/src/win/poll.c
+++ b/deps/uv/src/win/poll.c
@@ -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) {
uv_req_t* req;
AFD_POLL_INFO* afd_poll_info;
- DWORD result;
+ int result;
/* Find a yet unsubmitted req to submit. */
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) {
AFD_POLL_INFO afd_poll_info;
- DWORD result;
+ int result;
afd_poll_info.Exclusive = TRUE;
afd_poll_info.NumberOfHandles = 1;
diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c
index e7cccd9c80..f9c53de0af 100644
--- a/deps/uv/src/win/process.c
+++ b/deps/uv/src/win/process.c
@@ -739,7 +739,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
}
}
*ptr_copy = NULL;
- assert(env_len == ptr - dst_copy);
+ assert(env_len == (size_t) (ptr - dst_copy));
/* sort our (UTF-16) copy */
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,
ptr,
(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");
}
}
@@ -815,7 +815,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
}
/* Terminate with an extra NULL. */
- assert(env_len == (ptr - dst));
+ assert(env_len == (size_t) (ptr - dst));
*ptr = L'\0';
uv__free(dst_copy);
diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c
index 398288ec1d..45bbe9689a 100644
--- a/deps/uv/src/win/tty.c
+++ b/deps/uv/src/win/tty.c
@@ -791,8 +791,9 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
if (KEV.uChar.UnicodeChar >= 0xDC00 &&
KEV.uChar.UnicodeChar < 0xE000) {
/* UTF-16 surrogate pair */
- WCHAR utf16_buffer[2] = { handle->tty.rd.last_utf16_high_surrogate,
- KEV.uChar.UnicodeChar};
+ WCHAR utf16_buffer[2];
+ utf16_buffer[0] = handle->tty.rd.last_utf16_high_surrogate;
+ utf16_buffer[1] = KEV.uChar.UnicodeChar;
char_len = WideCharToMultiByte(CP_UTF8,
0,
utf16_buffer,
diff --git a/deps/uv/src/win/winapi.h b/deps/uv/src/win/winapi.h
index cfbac52eb1..2a8adf6b26 100644
--- a/deps/uv/src/win/winapi.h
+++ b/deps/uv/src/win/winapi.h
@@ -4109,6 +4109,9 @@
#endif
/* from winternl.h */
+#if !defined(__UNICODE_STRING_DEFINED) && defined(__MINGW32_)
+#define __UNICODE_STRING_DEFINED
+#endif
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;