diff options
author | Joel Sherrill <joel@rtems.org> | 2019-03-14 14:25:18 -0500 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2019-03-14 14:25:18 -0500 |
commit | 31e8f1b7829947e9f335a19ae42177a7e6c10e88 (patch) | |
tree | 286622871ceba15bde288f3718dba4378e0d0b0a | |
parent | main_edit.c: Use strncpy() to eliminate potential buffer overflow. (diff) | |
download | rtems-31e8f1b7829947e9f335a19ae42177a7e6c10e88.tar.bz2 |
shmopen.c: Fix logically unreachable code (Coverity ID: 1399706, 1399714)
Closes #3694.
-rw-r--r-- | cpukit/posix/src/shmopen.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cpukit/posix/src/shmopen.c b/cpukit/posix/src/shmopen.c index ca8da00140..22b5868bda 100644 --- a/cpukit/posix/src/shmopen.c +++ b/cpukit/posix/src/shmopen.c @@ -195,7 +195,8 @@ static inline POSIX_Shm_Control *shm_allocate( static inline bool shm_access_ok( POSIX_Shm_Control *shm, int oflag ) { int flags; - if ( oflag & O_RDONLY ) { + + if ( (oflag & O_ACCMODE) == O_RDONLY ) { flags = RTEMS_FS_PERMS_READ; } else { flags = RTEMS_FS_PERMS_WRITE; @@ -286,7 +287,7 @@ int shm_open( const char *name, int oflag, mode_t mode ) rtems_filesystem_location_add_to_mt_entry( &iop->pathinfo ); flags = LIBIO_FLAGS_CLOSE_ON_EXEC; - if ( oflag & O_RDONLY ) { + if ( (oflag & O_ACCMODE) == O_RDONLY ) { flags |= LIBIO_FLAGS_READ; } else { flags |= LIBIO_FLAGS_READ_WRITE; |