From: Ulrich Drepper Date: Tue, 6 Jul 1999 15:40:36 +0000 (+0000) Subject: (_IO_new_fdopen): Set EINVAL if MODE is not allowed by the file access X-Git-Tag: cvs/glibc_2-1-2~335 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8c8e3c5ed1f9dcd4351bf7f7e6be2f4b6c3fac52;p=thirdparty%2Fglibc.git (_IO_new_fdopen): Set EINVAL if MODE is not allowed by the file access mode of the open file. --- diff --git a/libio/iofdopen.c b/libio/iofdopen.c index 40419bd267c..c71258e6315 100644 --- a/libio/iofdopen.c +++ b/libio/iofdopen.c @@ -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: