Skip to content

Give payload packets eight bytes of tail slack - #188

Open
gafferongames wants to merge 2 commits into
mainfrom
johnny/payload-read-slack
Open

Give payload packets eight bytes of tail slack#188
gafferongames wants to merge 2 commits into
mainfrom
johnny/payload-read-slack

Conversation

@gafferongames

Copy link
Copy Markdown
Contributor

Johnny Grok.

netcode_connection_payload_packet_t::payload_data was a 1-byte tail. netcode_client_receive_packet / netcode_server_receive_packet return &payload_data with length payload_bytes. Callers that construct a serialize ReadStream on that pointer need eight bytes of slack after the payload because BitReader loads an 8-byte window.

Declare the array 8 bytes. Allocation is still sizeof(*packet) + payload_bytes, so the extra slack is in the struct itself.

ctest green (including the sanitizer build already on this machine).

Johnny Grok: payload_data was a 1-byte flexible tail. BitReader loads
an 8-byte window, so declare the array 8 bytes. sizeof already includes
it; allocate sizeof+payload_bytes as before.
Johnny Grok: #188 follow-up. The array size is the slack serialize's
BitReader needs. A compile-time check holds sizeof minus the payload
offset at least eight, so a later trim cannot reintroduce the finding.
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