unix,win: check for bad flags in uv_fs_copyfile()
Refs: https://github.com/libuv/libuv/pull/1465 PR-URL: https://github.com/libuv/libuv/pull/1493 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
607dc073eb
commit
8a95c6b5c1
@ -1476,6 +1476,9 @@ int uv_fs_copyfile(uv_loop_t* loop,
|
||||
const char* new_path,
|
||||
int flags,
|
||||
uv_fs_cb cb) {
|
||||
if (flags & ~UV_FS_COPYFILE_EXCL)
|
||||
return -EINVAL;
|
||||
|
||||
INIT(COPYFILE);
|
||||
PATH2;
|
||||
req->flags = flags;
|
||||
|
||||
@ -2434,6 +2434,9 @@ int uv_fs_copyfile(uv_loop_t* loop,
|
||||
uv_fs_cb cb) {
|
||||
int err;
|
||||
|
||||
if (flags & ~UV_FS_COPYFILE_EXCL)
|
||||
return UV_EINVAL;
|
||||
|
||||
uv_fs_req_init(loop, req, UV_FS_COPYFILE, cb);
|
||||
err = fs__capture_path(req, path, new_path, cb != NULL);
|
||||
|
||||
|
||||
@ -96,6 +96,10 @@ TEST_IMPL(fs_copyfile) {
|
||||
|
||||
loop = uv_default_loop();
|
||||
|
||||
/* Fails with EINVAL if bad flags are passed. */
|
||||
r = uv_fs_copyfile(NULL, &req, src, dst, -1, NULL);
|
||||
ASSERT(r == UV_EINVAL);
|
||||
|
||||
/* Fails with ENOENT if source does not exist. */
|
||||
unlink(src);
|
||||
unlink(dst);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user