Skip to content

fix(candid): bound length-prefixed allocations in header parser + release candid 0.10.35 - #758

Merged
lwshang merged 2 commits into
masterfrom
release-candid-0.10.35
Aug 11, 2026
Merged

fix(candid): bound length-prefixed allocations in header parser + release candid 0.10.35#758
lwshang merged 2 commits into
masterfrom
release-candid-0.10.35

Conversation

@lwshang

@lwshang lwshang commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Patch release. Bounds allocation for length-prefixed fields in the type-table header parser. See CHANGELOG.

🤖 Generated with Claude Code

…ease 0.10.35

Length-prefixed byte fields in the type-table parser (a future type's
payload, a service method's name) now grow their buffer incrementally
instead of reserving the declared length up front, so an out-of-range or
truncated length surfaces as an ordinary parse error. Wire format and
decoder error behaviour are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lwshang lwshang changed the title Release candid 0.10.35 fix(candid): bound length-prefixed allocations in header parser + release candid 0.10.35 Aug 11, 2026
@lwshang
lwshang marked this pull request as ready for review August 11, 2026 14:38
@lwshang
lwshang requested a review from a team as a code owner August 11, 2026 14:38
@zeropath-ai

zeropath-ai Bot commented Aug 11, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to f28574a.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rust/candid/src/binary_parser.rs
    Implement bounded, chunked read_len_prefixed to avoid oversized allocations
► rust/candid/src/binary_parser.rs
    Replace large count-based blob reads with bounded reads
► rust/candid/tests/type_table_alloc.rs
    Add tests for type-table header allocation safety
Bug Fix ► rust/candid/src/binary_parser.rs
    Handle short input and out-of-range lengths for length-prefixed blobs
Documentation/Changelog Update ► CHANGELOG.md
    Bump changelog entries for version 0.10.35 and related changes
Development/Build Configuration ► rust/candid/Cargo.toml
    Update candid_derive dependency version to 0.10.35
Development/Build Configuration ► rust/candid_derive/Cargo.toml
    Update version to 0.10.35

marc0olo
marc0olo previously approved these changes Aug 11, 2026

@marc0olo marc0olo 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.

Review content removed. Follow-up offline.

@marc0olo
marc0olo dismissed their stale review August 11, 2026 14:55

Dismissed; re-reviewing offline.

Valid messages decode identically, but the error returned for a truncated
byte field changes representation; drop the broader "decoder error
behaviour unchanged" claim to avoid overstating compatibility.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@marc0olo marc0olo 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.

Re-reviewed at f28574a. LGTM.

Checked the parser change against the binrw 0.15.2 internals it relies on, and confirmed the other length-prefixed read sites in binary_parser.rs behave correctly and need no equivalent change. The chunk size lines up with what Take::read_to_end reserves internally, so buffer growth stays linear. Loop termination and the short-read condition are correct.

Release hygiene is consistent: candid and candid_derive both to 0.10.35, the =0.10.35 pin matches, both Cargo.locks updated, and candid_parser's caret dependency correctly needs no bump. cargo test -p candid is green locally, and the new tests fail without the parser change.

The follow-up commit is CHANGELOG-only with no code delta, and the reworded compatibility note reads accurately now.

Non-blocking, pre-existing, worth a separate issue: the remaining #[br(count = len)] sites narrow a u64 wire length to usize. This PR keeps u64 end-to-end in the two fields it touches; the rest could be tidied up later.

@lwshang
lwshang merged commit b29eda1 into master Aug 11, 2026
18 checks passed
@lwshang
lwshang deleted the release-candid-0.10.35 branch August 11, 2026 14:59
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.

2 participants