diff options
author | Stefan Hoffmann <stefan991@gmail.com> | 2014-03-16 12:34:48 +0100 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-03 10:30:03 -0300 |
commit | 4a138137f78907703aa9215b45f46b8f37d84ae5 (patch) | |
tree | 914c3c343c298ed24f9a1d5704f9a25c52ab54c3 | |
parent | 23ee78a09356cfcc8f2fe9de479f58c8da84504f (diff) | |
download | rneovim-4a138137f78907703aa9215b45f46b8f37d84ae5.tar.gz rneovim-4a138137f78907703aa9215b45f46b8f37d84ae5.tar.bz2 rneovim-4a138137f78907703aa9215b45f46b8f37d84ae5.zip |
check readonly by trying to open the file for writing...
instead of mch_access, to avoid a possible race condition
-rw-r--r-- | src/fileio.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/src/fileio.c b/src/fileio.c index b7e674c63c..bf3a6dfb95 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -475,21 +475,11 @@ readfile ( } /* - * for UNIX: check readonly with perm and mch_access() - * for MSDOS and Amiga: check readonly by trying to open the file for writing + * check readonly by trying to open the file for writing */ file_readonly = FALSE; if (read_stdin) { } else if (!read_buffer) { -#ifdef USE_MCH_ACCESS - if ( -# ifdef UNIX - !(perm & 0222) || -# endif - mch_access((char *)fname, W_OK)) - file_readonly = TRUE; - fd = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0); -#else if (!newfile || readonlymode || (fd = mch_open((char *)fname, O_RDWR | O_EXTRA, 0)) < 0) { @@ -497,7 +487,6 @@ readfile ( /* try to open ro */ fd = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0); } -#endif } if (fd < 0) { /* cannot open at all */ |