Skip to content

THRIFT-6056: Limit struct read/write recursion depth in Dart library#3561

Draft
Jens-G wants to merge 1 commit into
apache:masterfrom
Jens-G:dart-recursion-depth
Draft

THRIFT-6056: Limit struct read/write recursion depth in Dart library#3561
Jens-G wants to merge 1 commit into
apache:masterfrom
Jens-G:dart-recursion-depth

Conversation

@Jens-G
Copy link
Copy Markdown
Member

@Jens-G Jens-G commented May 28, 2026

Summary

  • Adds _recursionDepth counter, incrementRecursionDepth() / decrementRecursionDepth() to TProtocol
  • Limit is 64; throws TProtocolError with TProtocolErrorType.DEPTH_LIMIT on excess
  • Dart generator wraps struct read/write bodies with try/finally to guarantee counter restoration

Test plan

  • lib/dart/test/protocol/t_protocol_recursion_depth_test.dart — covers allow/reject/restore
  • dart test in lib/dart passes

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

Client: dart

Add _recursionDepth counter and incrementRecursionDepth() /
decrementRecursionDepth() methods to TProtocol, with a hard limit of
64.  Update the Dart generator to call these methods around the struct
read/write body using try/finally so the counter is always restored.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jens-G Jens-G requested review from fishy and mhlakhani as code owners May 28, 2026 11:47
@mergeable mergeable Bot added dart Pull requests that update Dart code compiler labels May 28, 2026
@Jens-G Jens-G marked this pull request as draft May 28, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler dart Pull requests that update Dart code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant