Skip to content

fix(std/fs): reject null write buffers before opening files - #742

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
amandeavor:fix/fs-reject-null-write-buffers
Sep 25, 2026
Merged

LunaStev merged 1 commit into
wavefnd:masterfrom
amandeavor:fix/fs-reject-null-write-buffers

Conversation

@amandeavor

Copy link
Copy Markdown
Contributor

Summary

Positive-length null sources for fs_write_all / fs_append_all were only rejected by the OS write after the destination was opened, so invalid calls could truncate or create files. Reject src == null && len > 0 before open (same pattern as fs_read_all), returning IO_ERR_INVALID. Zero-length writes stay allowed.

Closes #738

Changes

  • std/fs/file.wave: null+positive-length guard in fs_write_all and fs_append_all (portable write/append wrappers already delegate here)
  • tests/fixtures/io/invalid_buffers.wave: cover existing and missing destinations, plus zero-length truncation on a dedicated path
  • tools/test_std_io_runtime.py: assert existing.bin is preserved and missing paths are not created

Test plan

  • Extended invalid-buffer fixture and runtime assertions
  • cargo test --test std_io_regressions (native LLVM host)

Positive-length null sources for fs_write_all and fs_append_all were only
detected by the OS write after the destination was already opened, which
truncated or created files for invalid input. Match fs_read_all and return
IO_ERR_INVALID before open when src is null and len > 0. Extend the
invalid-buffer fixture and runtime assertions for existing and missing paths.

Closes wavefnd#738

Signed-off-by: Aman Awasthi <amandeavor@gmail.com>
Copilot AI lite review requested due to automatic review settings September 25, 2026 07:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@LunaStev LunaStev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

@LunaStev
LunaStev merged commit 8d66afc into wavefnd:master Sep 25, 2026
25 checks passed
@LunaStev LunaStev mentioned this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reject null write buffers before opening or truncating files

3 participants