mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
io: more guards against NULL filename (#7159)
References ac055d677a
References #4370
This commit is contained in:
parent
3c8d063786
commit
d258ac8ed2
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user