On Fri, Aug 19, 2016 at 09:45:32PM +0200, Bram Moolenaar wrote:
> There is a similar check already in fileio.c:
>
> # ifdef OPEN_CHR_FILES
> && !(S_ISCHR(perm) && is_dev_fd_file(fname))
> /* ... or a character special file named /dev/fd/<n> */
> # endif
Oh, well, that's useful. Updated patch attached.
Thanks,
Danek
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/buffer.c b/src/buffer.c
index 4f68882..9ff9435 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -220,6 +220,9 @@ open_buffer(
# ifdef S_ISSOCK
|| S_ISSOCK(perm)
# endif
+# ifdef OPEN_CHR_FILES
+ || (S_ISCHR(perm) && is_dev_fd_file(curbuf->b_ffname))
+# endif
))
read_fifo = TRUE;
if (read_fifo)
diff --git a/src/fileio.c b/src/fileio.c
index 3c3d548..3a90262 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -27,9 +27,8 @@
/* Is there any system that doesn't have access()? */
#define USE_MCH_ACCESS
-#if (defined(sun) || defined(__FreeBSD__)) && defined(S_ISCHR)
-# define OPEN_CHR_FILES
-static int is_dev_fd_file(char_u *fname);
+#ifdef OPEN_CHR_FILES
+int is_dev_fd_file(char_u *fname);
#endif
#ifdef FEAT_MBYTE
static char_u *next_fenc(char_u **pp);
@@ -2725,7 +2724,7 @@ failed:
* some shells on some operating systems, e.g., bash on SunOS.
* Do not accept "/dev/fd/[012]", opening these may hang Vim.
*/
- static int
+ int
is_dev_fd_file(char_u *fname)
{
return (STRNCMP(fname, "/dev/fd/", 8) == 0
diff --git a/src/proto/fileio.pro b/src/proto/fileio.pro
index 748bf4c..30582d4 100644
--- a/src/proto/fileio.pro
+++ b/src/proto/fileio.pro
@@ -1,6 +1,7 @@
/* fileio.c */
void filemess(buf_T *buf, char_u *name, char_u *s, int attr);
int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T
lines_to_skip, linenr_T lines_to_read, exarg_T *eap, int flags);
+int is_dev_fd_file(char_u *fname);
int prep_exarg(exarg_T *eap, buf_T *buf);
void set_file_options(int set_options, exarg_T *eap);
void set_forced_fenc(exarg_T *eap);
diff --git a/src/vim.h b/src/vim.h
index 88d4850..23da917 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -2268,6 +2268,11 @@ typedef enum
# endif
#endif
+/* Are we ever likely to open character-special files? */
+#if (defined(sun) || defined(__FreeBSD__)) && defined(S_ISCHR)
+# define OPEN_CHR_FILES
+#endif
+
#define SIGN_BYTE 1 /* byte value used where sign is displayed;
attribute value is sign type */