mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-24 07:46:42 +00:00
libc: limit fcntl(F_SETFL) to file-status flags
This fixes unintended (and unpermitted) changes of O_ACCMODE bits.
This commit is contained in:
parent
e11addec7d
commit
732215a83f
@ -1108,7 +1108,11 @@ int Libc::Vfs_plugin::fcntl(File_descriptor *fd, int cmd, long arg)
|
||||
case F_SETFD: fd->cloexec = arg == FD_CLOEXEC; return 0;
|
||||
|
||||
case F_GETFL: return fd->flags;
|
||||
case F_SETFL: fd->flags = arg; return 0;
|
||||
case F_SETFL: {
|
||||
/* only the specified flags may be changed */
|
||||
long const mask = (O_NONBLOCK | O_APPEND | O_ASYNC | O_FSYNC);
|
||||
fd->flags = (fd->flags & ~mask) | (arg & mask);
|
||||
} return 0;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user