Changes since version 1.47.0: * misc: remove deprecated stalebot file (Jameson Nash) * build: disable windows asan buildbot (Ben Noordhuis) * test: don't run tcp_writealot under msan (Ben Noordhuis) * build,win: remove extraneous -lshell32 (Ben Noordhuis) * unix: ignore ifaddrs with NULL ifa_addr (Stephen Gallagher) * unix,win: utility for setting priority for thread (Hao Hu) * pipe: add back error handling to connect / bind (Jameson Nash) * test: check if ipv6 link-local traffic is routable (Ben Noordhuis) * win: remove check for UV_PIPE_NO_TRUNCATE (Jameson Nash) * linux: disable io_uring on hppa below kernel 6.1.51 (matoro) * unix,win: fix read past end of pipe name buffer (Ben Noordhuis) * unix: unbreak macOS < 10.14 (Sergey Fedorov) * aix: disable ipv6 link local (Abdirahim Musse) * doc: move cjihrig to emeriti (cjihrig) * unix: correct pwritev conditional (Bo Anderson) * test_fs.c: Fix issue on 32-bit systems using btrfs (Stephen Gallagher) * misc: ignore libuv-release-tool files (Jameson Nash) * win: honor NoDefaultCurrentDirectoryInExePath env var (Ardi Nugraha) * idna: fix compilation warning (Saúl Ibarra Corretgé) * linux: remove HAVE_IFADDRS_H macro (Ben Noordhuis) * test: skip tcp-write-in-a-row on IBM i (Abdirahim Musse) * build,win: work around missing uuid.dll on MinGW (Anton Bachin) * win: stop using deprecated names (Matheus Izvekov) * unix,win: fix busy loop with zero timeout timers (Matheus Izvekov) * aix,ibmi: use uv_interface_addresses instead of getifaddrs (Abdirahim Musse) * linux: fix bind/connect for abstract sockets (Santiago Gimeno) * win: replace c99 comments with c89 comments (Trevor Flynn) * build: add .cache clangd folder to .gitignore (Juan José Arboleda) * unix: support full TCP keep-alive on Solaris (Andy Pan) * freebsd: fix F_KINFO file path handling (David Carlier) * linux: retry fs op if unsupported by io_uring (Santiago Gimeno) * freebsd: fix build on non-intel archs (David Carlier) * unix: optimize uv__tcp_keepalive cpp directives (Andy Pan) * linux: disable io_uring on ppc64 and ppc64le (Brad King) * doc: add very basic Security Policy document (Santiago Gimeno) * build: re-enable msvc-asan job on CI (Jameson Nash) * win/spawn: optionally run executable paths with no file extension (Brad King) * win: fix ESRCH implementation (Jameson Nash) * unix,win: reset the timer queue on stop (Santiago Gimeno) * fix: always zero-terminate idna output (Ben Noordhuis) * fix: reject zero-length idna inputs (Ben Noordhuis) * test: empty strings are not valid IDNA (Santiago Gimeno) * Merge pull request from GHSA-f74f-cvh7-c6q6 (Ben Noordhuis) -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEYS8OrZQBYiN530QC8ow8jaM8A74FAmXD5fwACgkQ8ow8jaM8 A76H+g/9F2O6hXWfm5LACvIRhcDovK1NLprTp5Ae5qA9klSDzClxi6n7/B9NtDhv X2EwEXhQpc/Y600dbfcmKr6P5Gt2FDhjO3iy9gCrkUN+ZHV7kRCb8dmp+eyGcOag uKqkkpZN6aiT0Jp4H4x66VnSotvLeilHzs16+A3/r5wUNmqzhj0cG/UVaDyZfYEH NCqv5MFw2N9qO5lnsu2g1sDEujnjWhXUcY9D1vVUDf63CU09n+lz1LKRB5LKEGRy bPF/IjuxJAJQA+gsgj1dP2nuUH8IGhNOpkQ2WG8wEuPp6hahGvND4YovP/sDY7pV 9oo+73v1boAlYVS9IhAINVnKiPJx7tHJQvMcmgezSBCrd6v+PoWfL4A9oAWOp1qX ju+PC2Xk7E9Kt5gC9hjDzdMt6nw7Ab5pJ3ZcVF/2Sq27w0T4nxAOOpAt7JnJ53ug o26RWlO9NvBe30Uh2fwqye1UuL17Qjo7Y+ztrMQGmeV+RW693xqZ/bnVOhQupfqI fJNl1BBgInT9IU+A8ZtHeDuRf04hEit0rzS/yGrcHa1bHEHorG5W52nazYIsQURM hwWBDQ2dH2iTogHGdQ/CKdMGwuo+RwCavBXCHu03jf10hy+ImHF5ifJA7WLeH0oF QlCmeJl/26sOHlEa7wQnjhzh7YNg6JDuq6K22a9iR5vnduK1ByU= =67rH -----END PGP SIGNATURE----- Merge tag 'v1.48.0' into merge_1.48.0
227 lines
5.6 KiB
C
227 lines
5.6 KiB
C
/* Copyright Joyent, Inc. and other Node 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 <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
|
|
#ifdef _WIN32
|
|
# define BAD_PIPENAME "bad-pipe"
|
|
#else
|
|
# define BAD_PIPENAME "/path/to/unix/socket/that/really/should/not/be/there"
|
|
#endif
|
|
|
|
|
|
static int close_cb_called = 0;
|
|
static int connect_cb_called = 0;
|
|
|
|
|
|
static void close_cb(uv_handle_t* handle) {
|
|
ASSERT_NOT_NULL(handle);
|
|
close_cb_called++;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_bind_error_addrinuse) {
|
|
uv_pipe_t server1, server2;
|
|
int r;
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server1, 0);
|
|
ASSERT_OK(r);
|
|
r = uv_pipe_bind(&server1, TEST_PIPENAME);
|
|
ASSERT_OK(r);
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server2, 0);
|
|
ASSERT_OK(r);
|
|
r = uv_pipe_bind(&server2, TEST_PIPENAME);
|
|
ASSERT_EQ(r, UV_EADDRINUSE);
|
|
|
|
r = uv_listen((uv_stream_t*)&server1, SOMAXCONN, NULL);
|
|
ASSERT_OK(r);
|
|
r = uv_listen((uv_stream_t*)&server2, SOMAXCONN, NULL);
|
|
ASSERT_EQ(r, UV_EINVAL);
|
|
|
|
uv_close((uv_handle_t*)&server1, close_cb);
|
|
uv_close((uv_handle_t*)&server2, close_cb);
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
|
|
ASSERT_EQ(2, close_cb_called);
|
|
|
|
MAKE_VALGRIND_HAPPY(uv_default_loop());
|
|
return 0;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_bind_error_addrnotavail) {
|
|
uv_pipe_t server;
|
|
int r;
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server, 0);
|
|
ASSERT_OK(r);
|
|
|
|
r = uv_pipe_bind(&server, BAD_PIPENAME);
|
|
ASSERT_EQ(r, UV_EACCES);
|
|
|
|
uv_close((uv_handle_t*)&server, close_cb);
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
|
|
ASSERT_EQ(1, close_cb_called);
|
|
|
|
MAKE_VALGRIND_HAPPY(uv_default_loop());
|
|
return 0;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_bind_error_inval) {
|
|
uv_pipe_t server;
|
|
int r;
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server, 0);
|
|
ASSERT_OK(r);
|
|
r = uv_pipe_bind(&server, TEST_PIPENAME);
|
|
ASSERT_OK(r);
|
|
r = uv_pipe_bind(&server, TEST_PIPENAME_2);
|
|
ASSERT_EQ(r, UV_EINVAL);
|
|
|
|
uv_close((uv_handle_t*)&server, close_cb);
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
|
|
ASSERT_EQ(1, close_cb_called);
|
|
|
|
MAKE_VALGRIND_HAPPY(uv_default_loop());
|
|
return 0;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_listen_without_bind) {
|
|
#if defined(NO_SELF_CONNECT)
|
|
RETURN_SKIP(NO_SELF_CONNECT);
|
|
#endif
|
|
uv_pipe_t server;
|
|
int r;
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server, 0);
|
|
ASSERT_OK(r);
|
|
|
|
r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL);
|
|
ASSERT_EQ(r, UV_EINVAL);
|
|
|
|
uv_close((uv_handle_t*)&server, close_cb);
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
|
|
ASSERT_EQ(1, close_cb_called);
|
|
|
|
MAKE_VALGRIND_HAPPY(uv_default_loop());
|
|
return 0;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_bind_error_long_path) {
|
|
char path[2048];
|
|
uv_pipe_t server;
|
|
int r;
|
|
|
|
memset(path, '.', sizeof(path) - 1);
|
|
path[sizeof(path) - 1] = '\0';
|
|
|
|
r = uv_pipe_init(uv_default_loop(), &server, 0);
|
|
ASSERT(r == 0);
|
|
r = uv_pipe_bind(&server, path);
|
|
ASSERT(r == UV_ENAMETOOLONG);
|
|
|
|
uv_close((uv_handle_t*)&server, close_cb);
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
|
|
ASSERT(close_cb_called == 1);
|
|
|
|
MAKE_VALGRIND_HAPPY(uv_default_loop());
|
|
return 0;
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_bind_or_listen_error_after_close) {
|
|
uv_pipe_t server;
|
|
|
|
ASSERT_OK(uv_pipe_init(uv_default_loop(), &server, 0));
|
|
uv_close((uv_handle_t*) &server, NULL);
|
|
|
|
ASSERT_EQ(uv_pipe_bind(&server, TEST_PIPENAME), UV_EINVAL);
|
|
|
|
ASSERT_EQ(uv_listen((uv_stream_t*) &server, SOMAXCONN, NULL), UV_EINVAL);
|
|
|
|
ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT));
|
|
|
|
MAKE_VALGRIND_HAPPY(uv_default_loop());
|
|
return 0;
|
|
}
|
|
|
|
|
|
static void connect_overlong_cb(uv_connect_t* connect_req, int status) {
|
|
ASSERT_EQ(status, UV_EINVAL);
|
|
connect_cb_called++;
|
|
uv_close((uv_handle_t*) connect_req->handle, close_cb);
|
|
}
|
|
|
|
|
|
TEST_IMPL(pipe_overlong_path) {
|
|
uv_pipe_t pipe;
|
|
uv_connect_t req;
|
|
|
|
ASSERT_OK(uv_pipe_init(uv_default_loop(), &pipe, 0));
|
|
|
|
#ifndef _WIN32
|
|
char path[512];
|
|
memset(path, '@', sizeof(path));
|
|
ASSERT_EQ(UV_ENAMETOOLONG,
|
|
uv_pipe_bind2(&pipe, path, sizeof(path), UV_PIPE_NO_TRUNCATE));
|
|
ASSERT_EQ(UV_ENAMETOOLONG,
|
|
uv_pipe_connect2(&req,
|
|
&pipe,
|
|
path,
|
|
sizeof(path),
|
|
UV_PIPE_NO_TRUNCATE,
|
|
(uv_connect_cb) abort));
|
|
ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT));
|
|
#endif
|
|
|
|
ASSERT_EQ(UV_EINVAL, uv_pipe_bind(&pipe, ""));
|
|
uv_pipe_connect(&req,
|
|
&pipe,
|
|
"",
|
|
(uv_connect_cb) connect_overlong_cb);
|
|
ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT));
|
|
|
|
ASSERT_EQ(1, connect_cb_called);
|
|
ASSERT_EQ(1, close_cb_called);
|
|
|
|
MAKE_VALGRIND_HAPPY(uv_default_loop());
|
|
return 0;
|
|
|
|
}
|