aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-11-14 22:59:58 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-11-17 22:30:38 +0100
commitd135ba99b2945ca18fe3246cbb89a0920868ccf6 (patch)
tree240b68f0c472aaa7e3e1867240ab47b6079fbd0b /src
parent07931ed1c8cc749222a513cba5bdf300067646bc (diff)
downloadrneovim-d135ba99b2945ca18fe3246cbb89a0920868ccf6.tar.gz
rneovim-d135ba99b2945ca18fe3246cbb89a0920868ccf6.tar.bz2
rneovim-d135ba99b2945ca18fe3246cbb89a0920868ccf6.zip
os_open, os_stat: UV_EINVAL on NULL filename
EINVAL (instead of EFAULT) because that's what glibc does: https://github.com/bminor/glibc/blob/master/io/open.c#L35 os_nodetype: check for UV_EINVAL explicitly. ref #4370 ref https://github.com/neovim/neovim/issues/4370#issuecomment-344366571 ref ac055d677aa9eff9fca11cecb5ac7f7a4edb0265 ref #4772
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/fs.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 78627f8703..c5049acda9 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -172,7 +172,7 @@ int os_nodetype(const char *name)
| O_NONBLOCK
#endif
, 0);
- if (fd == -1) {
+ if (fd == UV_EINVAL) {
return NODE_OTHER; // open() failed.
}
@@ -394,9 +394,11 @@ end:
/// @param mode Permissions for the newly-created file (IGNORED if 'flags' is
/// not `O_CREAT` or `O_TMPFILE`), subject to the current umask
/// @return file descriptor, or libuv error code on failure
-int os_open(const char* path, int flags, int mode)
- FUNC_ATTR_NONNULL_ALL
+int os_open(const char *path, int flags, int mode)
{
+ if (path == NULL) { // uv_fs_open asserts on NULL. #7561
+ return UV_EINVAL;
+ }
int r;
RUN_UV_FS_FUNC(r, uv_fs_open, path, flags, mode, NULL);
return r;
@@ -603,12 +605,12 @@ int os_fsync(int fd)
/// Get stat information for a file.
///
-/// @return libuv return code.
+/// @return libuv return code, or -errno
static int os_stat(const char *name, uv_stat_t *statbuf)
FUNC_ATTR_NONNULL_ARG(2)
{
if (!name) {
- return UV_ENOENT;
+ return UV_EINVAL;
}
uv_fs_t request;
int result = uv_fs_stat(&fs_loop, &request, name, NULL);