Skip to content

Cap and lazily grow DATAFRAG reassembly buffers - #474

Open
ucsurf wants to merge 1 commit into
Atostek:masterfrom
ucsurf:fix/462-cap-datafrag-sample-allocation
Open

ucsurf wants to merge 1 commit into
Atostek:masterfrom
ucsurf:fix/462-cap-datafrag-sample-allocation

Conversation

@ucsurf

@ucsurf ucsurf commented Nov 19, 2026

Copy link
Copy Markdown

Refs #462 (item 1).

DATAFRAG sampleSize / data_size is taken from the submessage header and used in AssemblyBuffer::new to pre-allocate and zero-fill a buffer of that size (BytesMut::with_capacity + resize). A short datagram can claim up to about 4 GiB. MAX_ASSEMBLY_BUFFERS only caps how many incomplete samples are kept per writer.

This change rejects a claimed data_size above the existing MAX_WITHHELD_BYTES_PER_TOPIC cap (16 MiB) and grows the buffer only as fragments arrive, instead of pre-filling the whole sample.

This is a source-review patch. It has not been compiled or tested by us. CI and maintainer review should validate it; please compile and run the fragment_assembler tests, including the new reject_oversized_data_size test, before merging.

Ugur Celik (ucsurf), @ucsurf

DATAFRAG sampleSize is an untrusted header field. AssemblyBuffer::new
used to pre-allocate and zero-fill a buffer of that size, up to nearly
4 GiB, from one short datagram. Reject sizes above the existing
MAX_WITHHELD_BYTES_PER_TOPIC cap (16 MiB) and grow the buffer only as
fragments arrive.

This addresses public issue Atostek#462 item 1. The patch and the new unit
test have not been compiled or run.
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.

1 participant