commit b01a5c6bb76c2a932efa2f99447dd31367ce8510 (tree)
parent 1d8844dd5653d6496cbedbf75bdf8d367c16f690
Author: achan1989 <achan1989@gmail.com>
Date: Sun, 6 Oct 2024 09:47:12 +0100
Explain why POLL_FD_READWRITE is not dangerous at sites of use
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/std/fs/Dir.zig b/lib/std/fs/Dir.zig
@@ -804,6 +804,8 @@ pub fn openFile(self: Dir, sub_path: []const u8, flags: File.OpenFlags) File.Ope
}
if (native_os == .wasi and !builtin.link_libc) {
var base: std.os.wasi.rights_t = .{};
+ // POLL_FD_READWRITE only grants extra rights if the corresponding FD_READ and/or FD_WRITE
+ // is also set.
if (flags.isRead()) {
base.FD_READ = true;
base.FD_TELL = true;
@@ -984,6 +986,8 @@ pub fn createFile(self: Dir, sub_path: []const u8, flags: File.CreateFlags) File
.FD_FILESTAT_SET_TIMES = true,
.FD_FILESTAT_SET_SIZE = true,
.FD_FILESTAT_GET = true,
+ // POLL_FD_READWRITE only grants extra rights if the corresponding FD_READ and/or
+ // FD_WRITE is also set.
.POLL_FD_READWRITE = true,
}, .{}),
};