diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-08-13 18:46:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-13 18:46:09 +0200 |
commit | d258ac8ed21b3a202212792688b237d0741f6844 (patch) | |
tree | 72e6157e1c7789f49cfdeb7f6629b66c38ebcf83 | |
parent | 3c8d063786285987876b4e5ca98b301037945868 (diff) | |
download | rneovim-d258ac8ed21b3a202212792688b237d0741f6844.tar.gz rneovim-d258ac8ed21b3a202212792688b237d0741f6844.tar.bz2 rneovim-d258ac8ed21b3a202212792688b237d0741f6844.zip |
io: more guards against NULL filename (#7159)
References ac055d677aa9
References #4370
-rw-r--r-- | src/nvim/main.c | 1 | ||||
-rw-r--r-- | src/nvim/memfile.c | 1 | ||||
-rw-r--r-- | src/nvim/memline.c | 2 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 5 |
4 files changed, 8 insertions, 1 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index a46c1a58f8..3f828d7be9 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1825,6 +1825,7 @@ static int process_env(char *env, bool is_viminit) /// os_fileinfo_link() respectively for extra security. static bool file_owned(const char *fname) { + assert(fname != NULL); uid_t uid = getuid(); FileInfo file_info; bool file_owned = os_fileinfo(fname, &file_info) diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 9429703620..4428dd42aa 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -895,6 +895,7 @@ static bool mf_do_open(memfile_T *mfp, char_u *fname, int flags) { // fname cannot be NameBuff, because it must have been allocated. mf_set_fnames(mfp, fname); + assert(mfp->mf_fname != NULL); /// Extra security check: When creating a swap file it really shouldn't /// exist yet. If there is a symbolic link, this is most likely an attack. diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 55e7e01825..f28a9e60f4 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1460,6 +1460,7 @@ static int process_still_running; */ static time_t swapfile_info(char_u *fname) { + assert(fname != NULL); int fd; struct block0 b0; time_t x = (time_t)0; @@ -3135,6 +3136,7 @@ attention_message ( char_u *fname /* swap file name */ ) { + assert(buf->b_fname != NULL); time_t x, sx; char *p; diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 6ac9d682d7..78627f8703 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -859,8 +859,11 @@ bool os_fileinfo(const char *path, FileInfo *file_info) /// @param[out] file_info Pointer to a FileInfo to put the information in. /// @return `true` on success, `false` for failure. bool os_fileinfo_link(const char *path, FileInfo *file_info) - FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_NONNULL_ARG(2) { + if (path == NULL) { + return false; + } uv_fs_t request; int result = uv_fs_lstat(&fs_loop, &request, path, NULL); file_info->stat = request.statbuf; |