diff options
Diffstat (limited to 'libio')
-rw-r--r-- | libio/iofdopen.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libio/iofdopen.c b/libio/iofdopen.c index 3bfa40c..e8e32e0 100644 --- a/libio/iofdopen.c +++ b/libio/iofdopen.c @@ -77,10 +77,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: |