Repository navigation
fix(std/fs): reject null write buffers before opening files - #742
Merged
LunaStev merged 1 commit intoSep 25, 2026
Merged
Conversation
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>
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Positive-length
nullsources forfs_write_all/fs_append_allwere only rejected by the OS write after the destination was opened, so invalid calls could truncate or create files. Rejectsrc == null && len > 0before open (same pattern asfs_read_all), returningIO_ERR_INVALID. Zero-length writes stay allowed.Closes #738
Changes
std/fs/file.wave: null+positive-length guard infs_write_allandfs_append_all(portablewrite/appendwrappers already delegate here)tests/fixtures/io/invalid_buffers.wave: cover existing and missing destinations, plus zero-length truncation on a dedicated pathtools/test_std_io_runtime.py: assertexisting.binis preserved and missing paths are not createdTest plan
cargo test --test std_io_regressions(native LLVM host)