Jens Geyer created THRIFT-6293:
----------------------------------

             Summary: Haxe: add a container-size limit to TConfiguration
                 Key: THRIFT-6293
                 URL: https://issues.apache.org/jira/browse/THRIFT-6293
             Project: Thrift
          Issue Type: Sub-task
          Components: Haxe - Library
            Reporter: Jens Geyer


Sub-task of THRIFT-6291. {{org/apache/thrift/TConfiguration.hx}} exposes 
{{MaxMessageSize}}, {{MaxFrameSize}} and {{RecursionLimit}}, but nothing that 
bounds the declared element count of a list, set or map. See THRIFT-6291 for 
why the existing {{CheckReadBytesAvailable}} call does not cover that case.

h2. Suggested

* Add {{MaxContainerSize}} to {{org/apache/thrift/TConfiguration.hx}}, 
alongside the three existing fields, with the off convention THRIFT-6291 
settles.
* Enforce it in the three shared helpers in 
{{org/apache/thrift/protocol/TProtocolImplBase.hx}} 
({{CheckReadBytesAvailableSet}}, {{...List}}, {{...Map}} at lines 68, 73 and 
78). All nine call sites — binary, compact and JSON, each for list, set and map 
— already go through them, so no protocol needs its own check.
* Raise {{TProtocolException}} with {{SIZE_LIMIT}} when the count exceeds the 
limit, before any element is read.
* Off by default. No message accepted today may be rejected afterwards.

h2. Test

The test has to distinguish the new check from the existing byte-budget check, 
which the unfixed code already has. Write a *complete and well-formed* 
container of {{limit + 1}} single-byte elements, so every declared element 
really is on the wire and {{CheckReadBytesAvailable}} is satisfied. The test 
has to show two states — unfixed accepts the message, fixed answers 
{{SIZE_LIMIT}} — and the unfixed half must be *observed, not assumed*. Another 
guard may fire first (the recursion limit, the frame size, or the 
remaining-message budget as the test transport seeds it), which would quietly 
turn this into a test that passes either way.

Cover binary, compact and JSON, each for list, set and map, and at both 
{{limit}} and {{limit + 1}}.

_Drafted with AI assistance (Claude Opus 5); reviewed and filed by Jens Geyer._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to