authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-03-12 02:08:02+00:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-02 14:21:56+02:00
logceb84c647b5cf6ad6a17b829a78e1c079a6ab5a5
tree83afdd3b230ba1f28b4a51a5862f73dcf1a68e68
parent40891348923e48cbf371db5227acea7bb8b263aa
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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`.

1 files changed, 2 insertions(+), 0 deletions(-)

stage1/wasi.c+2
...@@ -1003,6 +1003,8 @@ uint32_t wasi_snapshot_preview1_fd_seek(uint32_t fd, uint64_t in_offset, uint32_...@@ -1003,6 +1003,8 @@ uint32_t wasi_snapshot_preview1_fd_seek(uint32_t fd, uint64_t in_offset, uint32_
1003 default: panic("unimplemented");1003 default: panic("unimplemented");
1004 }1004 }
10051005
1006 if (fds[fd].stream == NULL) return wasi_errno_success;
1007
1006 int seek_whence;1008 int seek_whence;
1007 switch (whence) {1009 switch (whence) {
1008 case wasi_whence_set:1010 case wasi_whence_set: