From fc8cc42e8f6418fb4fba7eabc021dad6404c58c7 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Wed, 3 Aug 2016 16:54:56 +0200 Subject: [PATCH 1/4] win: fix compilation on mingw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds missing define for UNLEN. PR-URL: https://github.com/libuv/libuv/pull/968 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Saúl Ibarra Corretgé --- src/win/util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/win/util.c b/src/win/util.c index 84a0e467..4a2e5012 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -54,6 +54,10 @@ /* The number of nanoseconds in one second. */ #define UV__NANOSEC 1000000000 +/* Max user name length, from iphlpapi.h */ +#ifndef UNLEN +# define UNLEN 256 +#endif /* Cached copy of the process title, plus a mutex guarding it. */ static char *process_title; From 7b07d18ad91ed2db58644185f1eaa60fdc7303af Mon Sep 17 00:00:00 2001 From: Matej Knopp Date: Mon, 1 Aug 2016 18:25:47 +0200 Subject: [PATCH 2/4] win: ensure 32-bit printf precision This commit removes a printf warning by casting a 64-bit value to 32 bits. Fixes: https://github.com/libuv/libuv/issues/955 PR-URL: https://github.com/libuv/libuv/pull/963 Reviewed-By: Colin Ihrig --- src/win/fs-event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/fs-event.c b/src/win/fs-event.c index f96a7bfd..03e4adc0 100644 --- a/src/win/fs-event.c +++ b/src/win/fs-event.c @@ -425,7 +425,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, } _snwprintf(filenamew, size, L"%s\\%.*s", handle->dirw, - file_info->FileNameLength / sizeof(WCHAR), + file_info->FileNameLength / (DWORD)sizeof(WCHAR), file_info->FileName); filenamew[size - 1] = L'\0'; From 39ee4121a1e921dd1dd23d05eb641f7f9174172b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 6 Aug 2016 06:19:41 +0200 Subject: [PATCH 3/4] darwin: handle EINTR in /dev/tty workaround MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On OS X, special files like /dev/null and /dev/tty don't work with kqueue. Libuv falls back to select() in that case but the initial probe didn't handle EINTR. Introduced in August 2012 in commit 731adaca ("unix: use select() for specific fds on OS X"), this bug was only ten days away from celebrating its fourth birthday. PR-URL: https://github.com/libuv/libuv/pull/979 Reviewed-By: Colin Ihrig Reviewed-By: Saúl Ibarra Corretgé --- src/unix/stream.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/unix/stream.c b/src/unix/stream.c index 2143cd88..d0c2f1ad 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -291,7 +291,10 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) { timeout.tv_sec = 0; timeout.tv_nsec = 1; - ret = kevent(kq, filter, 1, events, 1, &timeout); + do + ret = kevent(kq, filter, 1, events, 1, &timeout); + while (ret == -1 && errno == EINTR); + uv__close(kq); if (ret == -1) From a6acc822452b07564c0440bdb7909b7edc805013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 9 Aug 2016 12:21:07 +0100 Subject: [PATCH 4/4] test: fix OOB buffer access The test uses an annonymous pipe, which means the returned length will be 0. Fixes: https://github.com/libuv/libuv/issues/376 Fixes: https://github.com/libuv/libuv/issues/529 Refs: https://github.com/libuv/libuv/issues/264 PR-URL: https://github.com/libuv/libuv/pull/981 Reviewed-By: Ben Noordhuis --- test/test-pipe-getsockname.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-pipe-getsockname.c b/test/test-pipe-getsockname.c index 58041c02..e42931ea 100644 --- a/test/test-pipe-getsockname.c +++ b/test/test-pipe-getsockname.c @@ -231,7 +231,7 @@ TEST_IMPL(pipe_getsockname_blocking) { len1 = sizeof buf1; r = uv_pipe_getsockname(&pipe_client, buf1, &len1); ASSERT(r == 0); - ASSERT(buf1[len1 - 1] != 0); + ASSERT(len1 == 0); /* It's an annonymous pipe. */ r = uv_read_start((uv_stream_t*)&pipe_client, NULL, NULL); ASSERT(r == 0); @@ -240,7 +240,7 @@ TEST_IMPL(pipe_getsockname_blocking) { len2 = sizeof buf2; r = uv_pipe_getsockname(&pipe_client, buf2, &len2); ASSERT(r == 0); - ASSERT(buf2[len2 - 1] != 0); + ASSERT(len2 == 0); /* It's an annonymous pipe. */ r = uv_read_stop((uv_stream_t*)&pipe_client); ASSERT(r == 0);