]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(_IO_new_fdopen): Set EINVAL if MODE is not allowed by the file access
authorUlrich Drepper <drepper@redhat.com>
Tue, 6 Jul 1999 15:40:36 +0000 (15:40 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 6 Jul 1999 15:40:36 +0000 (15:40 +0000)
mode of the open file.

libio/iofdopen.c

index 40419bd267ccfeaf60d8671d5241d9f6d15b9919..c71258e6315bbf3f21b10ca234af4fb78f104dd4 100644 (file)
@@ -76,10 +76,15 @@ _IO_new_fdopen (fd, mode)
 #ifndef O_ACCMODE
 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
 #endif
-  if (fd_flags == -1
-      || ((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES))
-      || ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS)))
+  if (fd_flags == -1)
     return NULL;
+  
+  if (((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES))
+      || ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS)))
+    {
+      MAYBE_SET_EINVAL;
+      return NULL;
+    }
 
   /* The May 93 draft of P1003.4/D14.1 (redesignated as 1003.1b)
      [System Application Program Interface (API) Amendment 1: