From d8ac37fcc8d46adab6131db9c1a35131919f002b Mon Sep 17 00:00:00 2001 From: mlugg Date: Wed, 12 Mar 2025 02:08:02 +0000 Subject: [PATCH] stage1: fix `wasi_snapshot_preview1_fd_seek` on cache files `wasm2c` uses an interesting mechanism to "fake" the existence of cache directories. However, `wasi_snapshot_preview1_fd_seek` was not correctly integrated with this system, so previously crashed when run on a file in a cache directory due to trying to call `fseek` on a `FILE *` which was `NULL`. --- stage1/wasi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stage1/wasi.c b/stage1/wasi.c index 9d35efd280..0c9ca18c57 100644 --- a/stage1/wasi.c +++ b/stage1/wasi.c @@ -1003,6 +1003,8 @@ uint32_t wasi_snapshot_preview1_fd_seek(uint32_t fd, uint64_t in_offset, uint32_ default: panic("unimplemented"); } + if (fds[fd].stream == NULL) return wasi_errno_success; + int seek_whence; switch (whence) { case wasi_whence_set: