Repository navigation
fix: refuse a saved screen whose declared size is past the terminal limit - #602
Merged
vyncint merged 1 commit intoOct 22, 2026
Merged
Conversation
…imit Screen::parse allocated cols x rows cells from the header before reading any line, so a 31-byte file declaring 65535x65535 aborted on a 206 GB allocation (vyncint#583). parse_header and the JSON reader now refuse a dimension above MAX_DIMENSION (1000) with an error that names it. Signed-off-by: berce <75228263+bercedev@users.noreply.github.com>
vyncint
approved these changes
Oct 22, 2026
vyncint
left a comment
Owner
There was a problem hiding this comment.
Thanks — clean fix. Verified: the cap has held on the builder and on resize since 0.5.0, so no release STABILITY covers ever wrote a larger screen and the compat promise holds; compat tests pass locally, and the old code aborts on the new test as you said.
6 of 7 tasks
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 & why
Closes #583
Screen::parseallocatedcols × rowscells from the header before reading any grid line, and the header was only checked for zero. A 31-byte file declaring65535x65535aborted on a 206 GB allocation.parse_header(screen/parse.rs) now refuses a dimension aboveMAX_DIMENSIONwithError::Parse. For example:line 1: 65535x65535 is past the 1000-per-axis limit of a terminal, so no termlens wrote this screen.pub(crate)interminal.rswith its value and doc comment unchanged, so the two limits can't drift apart.screen/serde_impl.rs) applies the same limit, before the row and cell counts are compared.1000x1000screen still parses.I left the optional repeated-span-lines part of the issue out to keep this to one change.
Tests (
tests/compat.rs):a_declared_size_past_the_terminal_limit_is_refused_before_allocating:65535x65535,1001x1and1x1001each give anError::Parsenaming the size and the limit, and1000x1000parses.json::a_json_size_past_the_terminal_limit_is_refused: a corpusplain.jsonwithcolsandrowsset to 65535 is refused with the same message.With the old
parse.rsandserde_impl.rs, the compat test binary aborts withmemory allocation of 206152138800 bytes failed(SIGABRT).Checklist
cargo fmt --allandcargo clippy --workspace --all-targets --all-featuresare cleangit commit -s) — see CONTRIBUTING.md §5CHANGELOG.mdupdated under[Unreleased](user-facing changes only)cargo insta review, not blind-accepted (no snapshot changes)Checked with Rust 1.99.1, offline:
cargo test --workspace --all-features: 627 passed, 0 failed.cargo clippy -D warningsfor the workspace with all features, and for-p termlenswith default features, no default features, anddecodeonly.cargo fmt --all --check.RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --all-features.check-cli-contract.sh: PASS.check-dco.shandcheck-no-ai-attribution.shovermain..HEAD.This and #601 both add a
### Fixedsection under[Unreleased]. Whichever lands second needs a one-line merge inCHANGELOG.md, and I'll rebase this one if it's second.