From bfda20f334021034e6cd736ec3db4186f0af75cb Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 30 Nov 2023 20:58:06 +0900 Subject: [PATCH] wasi: make fdstat_set_flags return ENOTSUP for unimplemented flags --- libwasi/wasi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libwasi/wasi.c b/libwasi/wasi.c index 3aade4bb..a724be28 100644 --- a/libwasi/wasi.c +++ b/libwasi/wasi.c @@ -1437,12 +1437,15 @@ wasi_fd_fdstat_set_flags(struct exec_context *ctx, struct host_instance *hi, uint32_t fdflags = HOST_FUNC_PARAM(ft, params, 1, i32); struct wasi_fdinfo *fdinfo = NULL; int ret; + if ((fdflags & ~WASI_FDFLAG_NONBLOCK) != 0) { + ret = ENOTSUP; + goto fail; + } ret = wasi_fd_lookup(wasi, wasifd, &fdinfo); if (ret != 0) { goto fail; } fdinfo->blocking = ((fdflags & WASI_FDFLAG_NONBLOCK) == 0); - /* TODO implement other flags */ fail: wasi_fdinfo_release(wasi, fdinfo); HOST_FUNC_RESULT_SET(ft, results, 0, i32, wasi_convert_errno(ret));