authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-03-12 02:08:02+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-04-02 05:57:50+01:00
logd8ac37fcc8d46adab6131db9c1a35131919f002b
tree4980249c51f0ba0c8101a4d64e66f0c09c19dc6b
parent87209954a74bbf9b82b7ab24c0389a4a133edd31
signaturelock-open Commit is signed but in an unrecognized format.

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: