kernel/vfs: Validate that only one of O_RDWR or O_WRONLY is used, if any.
Otherwise we will have open modes that could have both and lead to confusion in code that presumes only one will be set. This catches the cause of some ported software (e.g. Wayland layer) misbehaving with ramfs mounted in /var/shared_memory: the ramfs does not properly handle both flags set, and due to another bug, they are for shm_open'ed files.
This commit is contained in:
parent
2c6cf678e6
commit
9bc250e28d
@ -2831,6 +2831,9 @@ get_new_fd(int type, struct fs_mount* mount, struct vnode* vnode,
|
||||
&& (type == FDTYPE_FILE || type == FDTYPE_DIR))
|
||||
return B_BUSY;
|
||||
|
||||
if ((openMode & O_RDWR) != 0 && (openMode & O_WRONLY) != 0)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
descriptor = alloc_fd();
|
||||
if (!descriptor)
|
||||
return B_NO_MEMORY;
|
||||
|
Loading…
Reference in New Issue
Block a user