fix(truncate): enforce VFS limits before resize#1616
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | cd5fc5a | Commit Preview URL | May 08 2026, 08:21 PM |
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.
What
Reject
truncatetarget sizes that exceed the active VFSmax_file_size/max_total_bytesbefore resizing the in-memory file buffer.Why
truncate -s 4G /tmp/ppreviously passed the builtin's hard-coded 4 GiB check and attempted to allocate/zero-fill beforewrite_fileenforced default 10 MB VFS limits.How
ctx.fs.limits()-derived validation.usize::try_frombefore allocation to avoid truncating oversized lengths on narrow platforms.Risk
Checklist
Verification
CARGO_BUILD_JOBS=1 cargo test -p bashkit --lib builtins::truncate::tests::rejects_target_above_vfs_limit_before_write --all-featuresfailed before the fix withcannot write ... file too large, then passed after the fix.CARGO_BUILD_JOBS=1 cargo test -p bashkit --lib builtins::truncate::tests --all-featuresjust pre-prcargo run -p bashkit-cli -- -c "truncate -s 4G /tmp/p; echo exit=\$?; test ! -e /tmp/p && echo no-file"