From 4a138137f78907703aa9215b45f46b8f37d84ae5 Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Sun, 16 Mar 2014 12:34:48 +0100 Subject: check readonly by trying to open the file for writing... instead of mch_access, to avoid a possible race condition --- src/fileio.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src') 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 */ -- cgit