libuv: fix pipe_getsockname_blocking regression
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
From 2165edb245f11031ec7606a7541f4b87388dbec9 Mon Sep 17 00:00:00 2001
|
||||
From: Martell Malone <martellmalone@gmail.com>
|
||||
Date: Sat, 27 Jun 2015 23:41:22 +0100
|
||||
Subject: [PATCH] Revert "fs, pipe: no trailing terminator in exact sized
|
||||
buffers"
|
||||
|
||||
This reverts commit 1e59ab1d49bace6d43726b076d2e820f318c53f9.
|
||||
|
||||
diff --git a/docs/src/fs_event.rst b/docs/src/fs_event.rst
|
||||
index 681ae52..e09dbad 100644
|
||||
--- a/docs/src/fs_event.rst
|
||||
+++ b/docs/src/fs_event.rst
|
||||
@@ -102,7 +102,4 @@ API
|
||||
is not big enough UV_ENOBUFS will be returned and len will be set to the
|
||||
required size.
|
||||
|
||||
- .. versionchanged:: 1.3.0 the returned length no longer includes the terminating null byte,
|
||||
- and the buffer is not null terminated.
|
||||
-
|
||||
.. seealso:: The :c:type:`uv_handle_t` API functions also apply.
|
||||
diff --git a/docs/src/fs_poll.rst b/docs/src/fs_poll.rst
|
||||
index 4efb244..9f694f1 100644
|
||||
--- a/docs/src/fs_poll.rst
|
||||
+++ b/docs/src/fs_poll.rst
|
||||
@@ -66,7 +66,4 @@ API
|
||||
is not big enough UV_ENOBUFS will be returned and len will be set to the
|
||||
required size.
|
||||
|
||||
- .. versionchanged:: 1.3.0 the returned length no longer includes the terminating null byte,
|
||||
- and the buffer is not null terminated.
|
||||
-
|
||||
.. seealso:: The :c:type:`uv_handle_t` API functions also apply.
|
||||
diff --git a/docs/src/pipe.rst b/docs/src/pipe.rst
|
||||
index df896a0..1a7d6b8 100644
|
||||
--- a/docs/src/pipe.rst
|
||||
+++ b/docs/src/pipe.rst
|
||||
@@ -69,9 +69,6 @@ API
|
||||
output. If the buffer is not big enough ``UV_ENOBUFS`` will be returned and
|
||||
len will contain the required size.
|
||||
|
||||
- .. versionchanged:: 1.3.0 the returned length no longer includes the terminating null byte,
|
||||
- and the buffer is not null terminated.
|
||||
-
|
||||
.. c:function:: int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size)
|
||||
|
||||
Get the name of the Unix domain socket or the named pipe to which the handle
|
||||
diff --git a/src/fs-poll.c b/src/fs-poll.c
|
||||
index 44d47b8..a940ca7 100644
|
||||
--- a/src/fs-poll.c
|
||||
+++ b/src/fs-poll.c
|
||||
@@ -137,7 +137,7 @@ int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) {
|
||||
ctx = handle->poll_ctx;
|
||||
assert(ctx != NULL);
|
||||
|
||||
- required_len = strlen(ctx->path);
|
||||
+ required_len = strlen(ctx->path) + 1;
|
||||
if (required_len > *size) {
|
||||
*size = required_len;
|
||||
return UV_ENOBUFS;
|
||||
diff --git a/src/unix/pipe.c b/src/unix/pipe.c
|
||||
index 7f87a71..2ed75a6 100644
|
||||
--- a/src/unix/pipe.c
|
||||
+++ b/src/unix/pipe.c
|
||||
@@ -231,7 +231,7 @@ static int uv__pipe_getsockpeername(const uv_pipe_t* handle,
|
||||
addrlen -= offsetof(struct sockaddr_un, sun_path);
|
||||
else
|
||||
#endif
|
||||
- addrlen = strlen(sa.sun_path);
|
||||
+ addrlen = strlen(sa.sun_path) + 1;
|
||||
|
||||
|
||||
if (addrlen > *size) {
|
||||
diff --git a/src/uv-common.c b/src/uv-common.c
|
||||
index 4b9901f..c6fb575 100644
|
||||
--- a/src/uv-common.c
|
||||
+++ b/src/uv-common.c
|
||||
@@ -437,7 +437,7 @@ int uv_fs_event_getpath(uv_fs_event_t* handle, char* buffer, size_t* size) {
|
||||
return UV_EINVAL;
|
||||
}
|
||||
|
||||
- required_len = strlen(handle->path);
|
||||
+ required_len = strlen(handle->path) + 1;
|
||||
if (required_len > *size) {
|
||||
*size = required_len;
|
||||
return UV_ENOBUFS;
|
||||
diff --git a/src/win/pipe.c b/src/win/pipe.c
|
||||
index 06cf0db..e64f726 100644
|
||||
--- a/src/win/pipe.c
|
||||
+++ b/src/win/pipe.c
|
||||
@@ -2030,9 +2030,9 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size)
|
||||
*size = 0;
|
||||
err = uv_translate_sys_error(GetLastError());
|
||||
goto error;
|
||||
- } else if (pipe_prefix_len + addrlen > *size) {
|
||||
- /* "\\\\.\\pipe" + name */
|
||||
- *size = pipe_prefix_len + addrlen;
|
||||
+ } else if (pipe_prefix_len + addrlen + 1 > *size) {
|
||||
+ /* "\\\\.\\pipe" + name + '\0' */
|
||||
+ *size = pipe_prefix_len + addrlen + 1;
|
||||
err = UV_ENOBUFS;
|
||||
goto error;
|
||||
}
|
||||
@@ -2053,6 +2053,7 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size)
|
||||
}
|
||||
|
||||
addrlen += pipe_prefix_len;
|
||||
+ buffer[addrlen++] = '\0';
|
||||
*size = addrlen;
|
||||
|
||||
err = 0;
|
||||
diff --git a/test/test-fs-event.c b/test/test-fs-event.c
|
||||
index 0a2ba33..5fd8da4 100644
|
||||
--- a/test/test-fs-event.c
|
||||
+++ b/test/test-fs-event.c
|
||||
@@ -642,7 +642,6 @@ TEST_IMPL(fs_event_getpath) {
|
||||
len = sizeof buf;
|
||||
r = uv_fs_event_getpath(&fs_event, buf, &len);
|
||||
ASSERT(r == 0);
|
||||
- ASSERT(buf[len - 1] != 0);
|
||||
ASSERT(memcmp(buf, "watch_dir", len) == 0);
|
||||
r = uv_fs_event_stop(&fs_event);
|
||||
ASSERT(r == 0);
|
||||
diff --git a/test/test-fs-poll.c b/test/test-fs-poll.c
|
||||
index dbc1515..f4eb084 100644
|
||||
--- a/test/test-fs-poll.c
|
||||
+++ b/test/test-fs-poll.c
|
||||
@@ -172,7 +172,6 @@ TEST_IMPL(fs_poll_getpath) {
|
||||
ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb_fail, FIXTURE, 100));
|
||||
len = sizeof buf;
|
||||
ASSERT(0 == uv_fs_poll_getpath(&poll_handle, buf, &len));
|
||||
- ASSERT(buf[len - 1] != 0);
|
||||
ASSERT(0 == memcmp(buf, FIXTURE, len));
|
||||
|
||||
uv_close((uv_handle_t*) &poll_handle, close_cb);
|
||||
diff --git a/test/test-pipe-getsockname.c b/test/test-pipe-getsockname.c
|
||||
index 5e036f9..2634b09 100644
|
||||
--- a/test/test-pipe-getsockname.c
|
||||
+++ b/test/test-pipe-getsockname.c
|
||||
@@ -63,7 +63,6 @@ static void pipe_client_connect_cb(uv_connect_t* req, int status) {
|
||||
r = uv_pipe_getpeername(&pipe_client, buf, &len);
|
||||
ASSERT(r == 0);
|
||||
|
||||
- ASSERT(buf[len - 1] != 0);
|
||||
ASSERT(memcmp(buf, TEST_PIPENAME, len) == 0);
|
||||
|
||||
len = sizeof buf;
|
||||
@@ -113,7 +112,6 @@ TEST_IMPL(pipe_getsockname) {
|
||||
r = uv_pipe_getsockname(&pipe_server, buf, &len);
|
||||
ASSERT(r == 0);
|
||||
|
||||
- ASSERT(buf[len - 1] != 0);
|
||||
ASSERT(memcmp(buf, TEST_PIPENAME, len) == 0);
|
||||
|
||||
len = sizeof buf;
|
||||
@@ -144,7 +142,6 @@ TEST_IMPL(pipe_getsockname) {
|
||||
r = uv_pipe_getpeername(&pipe_client, buf, &len);
|
||||
ASSERT(r == 0);
|
||||
|
||||
- ASSERT(buf[len - 1] != 0);
|
||||
ASSERT(memcmp(buf, TEST_PIPENAME, len) == 0);
|
||||
|
||||
r = uv_run(loop, UV_RUN_DEFAULT);
|
||||
@@ -230,7 +227,6 @@ TEST_IMPL(pipe_getsockname_blocking) {
|
||||
len1 = sizeof buf1;
|
||||
r = uv_pipe_getsockname(&pipe_client, buf1, &len1);
|
||||
ASSERT(r == 0);
|
||||
- ASSERT(buf1[len1 - 1] != 0);
|
||||
|
||||
r = uv_read_start((uv_stream_t*)&pipe_client, NULL, NULL);
|
||||
ASSERT(r == 0);
|
||||
@@ -239,7 +235,6 @@ TEST_IMPL(pipe_getsockname_blocking) {
|
||||
len2 = sizeof buf2;
|
||||
r = uv_pipe_getsockname(&pipe_client, buf2, &len2);
|
||||
ASSERT(r == 0);
|
||||
- ASSERT(buf2[len2 - 1] != 0);
|
||||
|
||||
r = uv_read_stop((uv_stream_t*)&pipe_client);
|
||||
ASSERT(r == 0);
|
||||
--
|
||||
2.4.4
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
_realname=libuv
|
||||
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
|
||||
pkgver=1.6.1
|
||||
pkgrel=1
|
||||
pkgrel=2
|
||||
pkgdesc="Cross-platform asychronous I/O (mingw-w64)"
|
||||
arch=('any')
|
||||
url="https://github.com/libuv/libuv"
|
||||
@@ -12,11 +12,14 @@ license=("custom")
|
||||
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
|
||||
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
|
||||
options=('staticlibs' 'strip')
|
||||
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/libuv/libuv/archive/v${pkgver}.tar.gz")
|
||||
sha256sums=('f558ede285878d6a69f6a6d43b5df0241f3c35d62ac989477bdbd418badd83d7')
|
||||
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/libuv/libuv/archive/v${pkgver}.tar.gz"
|
||||
"0001-Revert-fs-pipe-no-trailing-terminator-in-exact-sized.patch")
|
||||
sha256sums=('f558ede285878d6a69f6a6d43b5df0241f3c35d62ac989477bdbd418badd83d7'
|
||||
'432203e598cefbad2193a3fbb98c2b4be59f256f26f6fe1ee98e80422e142aee')
|
||||
|
||||
prepare() {
|
||||
cd "$srcdir/${_realname}-${pkgver}"
|
||||
patch -p1 -i ${srcdir}/0001-Revert-fs-pipe-no-trailing-terminator-in-exact-sized.patch
|
||||
./autogen.sh
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user