[ 
https://issues.apache.org/jira/browse/THRIFT-6287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18116516#comment-18116516
 ] 

Jens Geyer commented on THRIFT-6287:
------------------------------------

We keep {{DEFAULT_CONTAINER_LIMIT = None}}, so this ticket does not lead to a 
change.

* Of the bindings that have a container-count limit (C++, Java, Python, D, 
Rust, c_glib), all default to no limit except D, whose finite default is new on 
master. Go gets an opt-in limit in THRIFT-6286, also off by default.
* Rust already bounds a declared count in two ways:
** {{check_container_size}} rejects a count whose elements could not fit into 
{{max_message_size}} (100 MB by default).
** Generated code reserves list capacity through {{prealloc_size}}, which caps 
it at 1024 elements. Sets and maps are {{BTreeSet}}/{{BTreeMap}} and reserve 
nothing.
* Whether container sizes should get finite defaults is a question for all 
bindings, not just Rust. {{doc/thrift-threat-model.md}} lists it as open 
question Q38.

Callers who want a limit can set it with 
{{TConfiguration::builder().max_container_size(...)}} and pass the 
configuration to {{TBinaryInputProtocol::with_config}} or 
{{TCompactInputProtocol::with_config}}. The input protocol factories cannot 
take a configuration yet. That is THRIFT-6296.

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

> Rust: max_container_size defaults to no limit
> ---------------------------------------------
>
>                 Key: THRIFT-6287
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6287
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Rust - Library
>            Reporter: Jens Geyer
>            Priority: Minor
>
> {{lib/rs/src/configuration.rs}} defines {{DEFAULT_CONTAINER_LIMIT = None}}, 
> so {{max_container_size}} is present in the configuration but inert unless a 
> caller sets it explicitly. The other bindings that expose a container-size 
> knob vary in their default, and Rust's is off.
> h2. Suggested
> Consider giving {{max_container_size}} a finite default. That is a 
> behavioural change for existing users, so it belongs in normal review rather 
> than a drive-by change.
> _Drafted with AI assistance (Claude Opus 4.8); reviewed and filed by Jens 
> Geyer._



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

Reply via email to