From dd8662b6d28236b60bb419390ea083695bbb2173 Mon Sep 17 00:00:00 2001 From: Nikolai Vavilov Date: Mon, 6 Jan 2020 19:37:21 +0200 Subject: [PATCH] win, fs: mkdir really return UV_EINVAL for invalid names Makes uv_fs_mkdir return UV_EINVAL for invalid directory names instead of UV_ENOENT. Refs: https://github.com/nodejs/node/issues/31177 PR-URL: https://github.com/libuv/libuv/pull/2601 Reviewed-By: Ben Noordhuis Reviewed-By: Santiago Gimeno --- src/win/fs.c | 3 ++- test/test-fs.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/win/fs.c b/src/win/fs.c index 3306b8da..a083b5e8 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -1218,7 +1218,8 @@ void fs__mkdir(uv_fs_t* req) { SET_REQ_RESULT(req, 0); } else { SET_REQ_WIN32_ERROR(req, GetLastError()); - if (req->sys_errno_ == ERROR_INVALID_NAME) + if (req->sys_errno_ == ERROR_INVALID_NAME || + req->sys_errno_ == ERROR_DIRECTORY) req->result = UV_EINVAL; } } diff --git a/test/test-fs.c b/test/test-fs.c index a8f65abc..0292a96b 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -4437,6 +4437,7 @@ TEST_IMPL(fs_invalid_mkdir_name) { loop = uv_default_loop(); r = uv_fs_mkdir(loop, &req, "invalid>", 0, NULL); ASSERT(r == UV_EINVAL); + ASSERT_EQ(UV_EINVAL, uv_fs_mkdir(loop, &req, "test:lol", 0, NULL)); return 0; }