You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validate reserved fields on Header, DbResponse, EmptyResponse decode
LeaderRequest.decode_body validates its body-level reserved uint64 is
zero; the corresponding Header, DbResponse, and EmptyResponse
decoders did not — three reserved words the upstream C protocol pins
to zero were silently accepted or not read at all. Asymmetry blocks
using those bits as a future schema-version signal and hides peer
corruption that should surface as a clean DecodeError.
Apply symmetric strict validation:
- Header.decode: reject non-zero `reserved` uint16 (message.h's `extra`
field).
- DbResponse.decode_body: require the full 8-byte body, read the
trailing uint32 reserved field, reject non-zero.
- EmptyResponse.decode_body: require the full 8-byte body, read the
uint64 reserved, reject non-zero.
Error wording mirrors LeaderRequest's phrasing
("<MessageName> reserved field must be 0, got {reserved}") for
consistency.
Updated tests:
- TestHeaderReservedField: add test_decode_rejects_nonzero_reserved.
- TestReservedFieldValidation (new): positive and negative cases for
DbResponse and EmptyResponse.
- test_decode_body_raises_on_short: DbResponse min body bumped from
4 to 8, EmptyResponse added (8).
- The prior test_empty_response_accepts_any_body pinned the lax
behaviour and is replaced by the new validation tests.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments