Skip to content

Reject trailing Brotli data to prevent infinite drain loops - #232

Open
illia-v wants to merge 1 commit into
python-hyper:mainfrom
illia-v:trailing-data
Open

illia-v wants to merge 1 commit into
python-hyper:mainfrom
illia-v:trailing-data

Conversation

@illia-v

@illia-v illia-v commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Reject trailing data after a complete stream, matching error check of the reference Brotli. This prevents infinite loops while draining the decoder.

Reproducer:

import brotlicffi as brotli  # or import brotli

data = brotli.compress(b"A" * (2**21)) + b"tail"
decoder = brotli.Decompressor()
decoder.process(data, output_buffer_limit=2**20)

while not decoder.can_accept_more_data():
    decoder.process(b"", output_buffer_limit=2**20)

Unpatched brotlicffi loops indefinitely. Patched brotlicffi and reference Brotli raise an error.

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