about summary refs log tree commit diff
path: root/libio/iopopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'libio/iopopen.c')
-rw-r--r--libio/iopopen.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libio/iopopen.c b/libio/iopopen.c
index 65337f8f28..a03cf636b2 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -98,18 +98,23 @@ _IO_proc_open (fp, command, mode)
     return NULL;
   if (_IO_pipe (pipe_fds) < 0)
     return NULL;
-  if (mode[0] == 'r')
+  if (mode[0] == 'r' && mode[1] == '\0')
     {
       parent_end = pipe_fds[0];
       child_end = pipe_fds[1];
       read_or_write = _IO_NO_WRITES;
     }
-  else
+  else if (mode[0] == 'w' && mode[1] == '\0')
     {
       parent_end = pipe_fds[1];
       child_end = pipe_fds[0];
       read_or_write = _IO_NO_READS;
     }
+  else
+    {
+      __set_errno (EINVAL);
+      return NULL;
+    }
   ((_IO_proc_file *) fp)->pid = child_pid = _IO_fork ();
   if (child_pid == 0)
     {