Skip to content

Add per-pull output cap to decoder#251

Merged
hyperxpro merged 1 commit into
mainfrom
per-pull-cap
Apr 26, 2026
Merged

Add per-pull output cap to decoder#251
hyperxpro merged 1 commit into
mainfrom
per-pull-cap

Conversation

@hyperxpro

Copy link
Copy Markdown
Owner

Motivation:

DecoderJNI.Wrapper.pull() may return large ByteBuffers (up to ~16 MiB) with no way to limit size. This makes decoding untrusted input unsafe or forces extra buffering in user code.

Modification:

  • Add per-call limit: pull(int maxBytes)
  • Add persistent limit: Wrapper(..., maxOutputChunkSize)
  • Add overloads in Decoder, BrotliInputStream, BrotliDecoderChannel
  • Add maxOutputSize to decompress(...) APIs (fail with IOException if exceeded)
  • Expose bounded output via JNI (nativePullBounded)

Result:

Callers can bound memory usage (per chunk or total) when decoding, without affecting existing usage.

@hyperxpro hyperxpro merged commit 3af3b97 into main Apr 26, 2026
61 checks passed
@hyperxpro hyperxpro deleted the per-pull-cap branch April 26, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant