Handle ambiguous fstflags on fd_filestat_set_times (#2892)

It's possible to set both `atim` and `atim_now` in the `fstflags`
parameter.  Same goes for `mtin` and `mtim_now`.  However, it's
ambiguous which time should be set in these two cases.  This commit
checks this and returns `EINVAL`.
This commit is contained in:
Yage Hu 2023-12-10 22:16:58 -08:00 committed by GitHub
parent 6cb2ea4935
commit bc2d8959dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1891,7 +1891,13 @@ wasmtime_ssp_fd_filestat_set_times(wasm_exec_env_t exec_env,
if ((fstflags if ((fstflags
& ~(__WASI_FILESTAT_SET_ATIM | __WASI_FILESTAT_SET_ATIM_NOW & ~(__WASI_FILESTAT_SET_ATIM | __WASI_FILESTAT_SET_ATIM_NOW
| __WASI_FILESTAT_SET_MTIM | __WASI_FILESTAT_SET_MTIM_NOW)) | __WASI_FILESTAT_SET_MTIM | __WASI_FILESTAT_SET_MTIM_NOW))
!= 0) != 0
|| (fstflags
& (__WASI_FILESTAT_SET_ATIM | __WASI_FILESTAT_SET_ATIM_NOW))
== (__WASI_FILESTAT_SET_ATIM | __WASI_FILESTAT_SET_ATIM_NOW)
|| (fstflags
& (__WASI_FILESTAT_SET_MTIM | __WASI_FILESTAT_SET_MTIM_NOW))
== (__WASI_FILESTAT_SET_MTIM | __WASI_FILESTAT_SET_MTIM_NOW))
return __WASI_EINVAL; return __WASI_EINVAL;
struct fd_object *fo; struct fd_object *fo;