[PR #635] [MERGED] Fix brotlidump.py crashing when complex prefix code has exactly 1 non-zero code length #1285

Open
opened 2026-01-29 20:53:20 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/google/brotli/pull/635
Author: @chylex
Created: 2/8/2018
Status: Merged
Merged: 2/8/2018
Merged by: @eustas

Base: masterHead: brotlidump-fix


📝 Commits (1)

  • 42955f8 Fix brotlidump.py crashing when complex prefix code has exactly 1 non-zero code length

📊 Changes

1 file changed (+4 additions, -3 deletions)

View changed files

📝 research/brotlidump.py (+4 -3)

📄 Description

According to the format specification regarding complex prefix codes:

If there are at least two non-zero code lengths, any trailing zero
code lengths are omitted, i.e., the last code length in the
sequence must be non-zero. In this case, the sum of (32 >> code
length) over all the non-zero code lengths must equal to 32.

If the lengths have been read for the entire code length alphabet
and there was only one non-zero code length, then the prefix code
has one symbol whose code has zero length.

The script does not handle a case where there is just 1 non-zero code
length where the sum rule doesn't apply, which causes a StopIteration
exception when it attempts to read past the list boundaries.

An example of such file is tests/testdata/mapsdatazrh.compressed. I made
sure this change doesn't break anything by processing all *.compressed
files from the testdata folder with no thrown exceptions.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/google/brotli/pull/635 **Author:** [@chylex](https://github.com/chylex) **Created:** 2/8/2018 **Status:** ✅ Merged **Merged:** 2/8/2018 **Merged by:** [@eustas](https://github.com/eustas) **Base:** `master` ← **Head:** `brotlidump-fix` --- ### 📝 Commits (1) - [`42955f8`](https://github.com/google/brotli/commit/42955f8edf351aac1d2a6655d943eb5d80858e55) Fix brotlidump.py crashing when complex prefix code has exactly 1 non-zero code length ### 📊 Changes **1 file changed** (+4 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `research/brotlidump.py` (+4 -3) </details> ### 📄 Description According to the format specification regarding complex prefix codes: > If there are at least two non-zero code lengths, any trailing zero > code lengths are omitted, i.e., the last code length in the > sequence must be non-zero. In this case, the sum of (32 >> code > length) over all the non-zero code lengths must equal to 32. > If the lengths have been read for the entire code length alphabet > and there was only one non-zero code length, then the prefix code > has one symbol whose code has zero length. The script does not handle a case where there is just 1 non-zero code length where the sum rule doesn't apply, which causes a StopIteration exception when it attempts to read past the list boundaries. An example of such file is tests/testdata/mapsdatazrh.compressed. I made sure this change doesn't break anything by processing all *.compressed files from the testdata folder with no thrown exceptions. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 20:53:20 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#1285