Fix get_maximum_output_size overflow on 32-bit targets#205
Merged
PSeitz merged 1 commit intoPSeitz:mainfrom Feb 19, 2026
Merged
Fix get_maximum_output_size overflow on 32-bit targets#205PSeitz merged 1 commit intoPSeitz:mainfrom
PSeitz merged 1 commit intoPSeitz:mainfrom
Conversation
dglittle
added a commit
to braid-org/diamond-types
that referenced
this pull request
Feb 15, 2026
Point lz4_flex dependency to dglittle/lz4_flex fork which fixes get_maximum_output_size() overflow on 32-bit targets. The original formula `input_len * 110 / 100` overflows u32 when input_len > ~39MB, causing compress_into to receive an undersized buffer and panic. See: PSeitz/lz4_flex#205 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
Thanks for the PR. I'd prefer to just cast input_size to u64. |
Cast input_len to u64 before multiplying by 110, avoiding overflow on 32-bit targets (e.g. wasm32) where `input_len * 110` overflows usize when input_len > 2^32 / 110 ≈ 39MB. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2fae275 to
4ff9d43
Compare
Contributor
Author
|
Sounds good -- I've updated the PR. Thanks! |
Owner
|
Thanks! |
rerun-sync bot
pushed a commit
to rerun-io/rerun
that referenced
this pull request
Mar 17, 2026
### Related * Closes RR-4067. * PSeitz/lz4_flex#205 ### What This bumps `lz4_flex` to `0.13.0` which includes the PR linked above. ### Testing 1. Open web viewer 2. Open DICOM recording 3. Menu -> Save recording... 4. Should not crash Source-Ref: b09682616fc15c6299351d3e31dc2d9a0b3c99ac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #204
Summary
get_maximum_output_sizeto avoidinput_len * 110overflow on 32-bit targets (e.g. wasm32)u32arithmeticProblem
On wasm32,
input_len * 110overflowsu32wheninput_len > ~39MB, causingcompress_intoto receive a vastly undersized buffer and panic.Fix
Replace
input_len * 110 / 100withinput_len + input_len / 100 * 10 + input_len % 100 * 10 / 100. Produces identical results without intermediate overflow.