Skip to content

Commit

Permalink
win: remove check for UV_PIPE_NO_TRUNCATE (libuv#4221)
Browse files Browse the repository at this point in the history
There is no length at which this gets truncated on Windows. The
underlying file system will just not successfully connect to a longer
path (in WTF-16 characters), which will return an error asynchronously
with the existing API.

Refs: libuv#4040
  • Loading branch information
vtjnash authored Nov 15, 2023
1 parent b9421d7 commit 35da5de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
12 changes: 0 additions & 12 deletions src/win/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,12 +722,6 @@ int uv_pipe_bind2(uv_pipe_t* handle,
return UV_EINVAL;
}

if (flags & UV_PIPE_NO_TRUNCATE) {
if (namelen > 256) {
return UV_EINVAL;
}
}

if (handle->flags & UV_HANDLE_BOUND) {
return UV_EINVAL;
}
Expand Down Expand Up @@ -886,12 +880,6 @@ int uv_pipe_connect2(uv_connect_t* req,
return UV_EINVAL;
}

if (flags & UV_PIPE_NO_TRUNCATE) {
if (namelen > 256) {
return UV_EINVAL;
}
}

if (handle->flags & UV_HANDLE_PIPESERVER) {
err = ERROR_INVALID_PARAMETER;
goto error;
Expand Down
7 changes: 5 additions & 2 deletions test/test-pipe-bind-error.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,14 @@ static void connect_overlong_cb(uv_connect_t* connect_req, int status) {


TEST_IMPL(pipe_overlong_path) {
char path[512];
uv_pipe_t pipe;
uv_connect_t req;

memset(path, '@', sizeof(path));
ASSERT_OK(uv_pipe_init(uv_default_loop(), &pipe, 0));

#ifndef _WIN32
char path[512];
memset(path, '@', sizeof(path));
ASSERT_EQ(UV_EINVAL,
uv_pipe_bind2(&pipe, path, sizeof(path), UV_PIPE_NO_TRUNCATE));
ASSERT_EQ(UV_EINVAL,
Expand All @@ -180,6 +182,7 @@ TEST_IMPL(pipe_overlong_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,
Expand Down

0 comments on commit 35da5de

Please sign in to comment.