Jens Geyer created THRIFT-6292:
----------------------------------
Summary: netstd: add a container-size limit to TConfiguration
Key: THRIFT-6292
URL: https://issues.apache.org/jira/browse/THRIFT-6292
Project: Thrift
Issue Type: Sub-task
Components: netstd - Library
Reporter: Jens Geyer
Sub-task of THRIFT-6291. {{Thrift/TConfiguration.cs}} 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 {{Thrift/TConfiguration.cs}}, alongside the three
existing properties, with the off convention THRIFT-6291 settles.
* Enforce it in the three shared helpers in {{Thrift/Protocol/TProtocol.cs}}
({{CheckReadBytesAvailable(TSet)}}, {{(TList)}}, {{(TMap)}} at lines 86, 91 and
96). Every container header in binary, compact and JSON already goes through
those three helpers, so no protocol needs its own check.
({{TCompactProtocol.ReadSetBeginAsync}} reaches them indirectly: it delegates
to {{ReadListBeginAsync}}.)
* 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)