Repository navigation
Reject undefined pixel fragment lengths before reading - #471
Merged
CPBridge merged 2 commits intoOct 21, 2026
Merged
Conversation
CPBridge
requested changes
Oct 21, 2026
CPBridge
left a comment
Collaborator
There was a problem hiding this comment.
As noted on #470 I am not convinced this is really an important problem, but on reflection I also don't see any harm in accepting this change, since a fragment should not have an odd number of bytes anyway, so 0xFFFFFFFF should never be encountered as a "true" fragment length.
However, I would rather not introduce a new test file just for this. Could you please add the test to the existing tests/test_io.py instead?
Contributor
Author
|
Moved the regression test into tests/test_io.py and removed the separate test file in fb78b20. The test assertions and production change are unchanged. |
CPBridge
approved these changes
Oct 21, 2026
Collaborator
|
Ok thank you @jdotc1 ! |
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 #470.
Reject an encapsulated fragment length of
0xFFFFFFFFbefore passing it to the stream'sread()method. This prevents an invalid fragment from requesting a nearly-4-GiB payload read when an offset table is supplied and the separate fragment scanner is bypassed.Add one mocked-stream regression that expects
OSErrorand verifies no payload read occurs. The test failed before the two-line fix and passed afterward. Validation used the actual reader method and new test loaded in isolation, with real pydicom tag handling and a mocked stream, without importing the full highdicom package. No large allocation, clinical files, codec, network, or full suite was used.This is malformed-input/resource hardening, not a demonstrated exploit or memory-exhaustion claim.