Skip to content

THRIFT-6054: Limit struct read/write recursion depth in Kotlin library#3559

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

THRIFT-6054: Limit struct read/write recursion depth in Kotlin library#3559
Jens-G wants to merge 1 commit into
apache:masterfrom
Jens-G:kotlin-recursion-depth

Conversation

@Jens-G
Copy link
Copy Markdown
Member

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

Summary

  • Adds recursion depth checking to TProtocol.readStruct() and TProtocol.writeStruct() — the helper methods used by all Kotlin-generated struct serialization code
  • Reuses the existing incrementRecursionDepth() / decrementRecursionDepth() infrastructure in TProtocol; decrement is guaranteed via try/finally
  • Limit is 64; throws TProtocolException(TProtocolException.DEPTH_LIMIT) on excess

Test plan

  • lib/kotlin/.../RecursionDepthTest.kt — covers allow/reject/restore
  • ./gradlew test in lib/kotlin passes

🤖 Generated with Claude Code

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

Client: kotlin

Add recursion depth checking to TProtocol.readStruct() and
TProtocol.writeStruct(), the helper methods used by Kotlin-generated
struct serialization code.  The depth counter and limit (64) are
managed by the existing incrementRecursionDepth() /
decrementRecursionDepth() infrastructure in TProtocol; the decrement
is now guaranteed via a try/finally block.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jens-G Jens-G requested review from fishy and jimexist as code owners May 28, 2026 11:47
@mergeable mergeable Bot added java Pull requests that update Java code kotlin 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

java Pull requests that update Java code kotlin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant