Skip to content

Validate ImageFileReader frame indices - #444

Merged
CPBridge merged 1 commit into
ImagingDataCommons:masterfrom
yinkev:bugfix/image-reader-frame-bounds
Jul 28, 2026
Merged

CPBridge merged 1 commit into
ImagingDataCommons:masterfrom
yinkev:bugfix/image-reader-frame-bounds

Conversation

@yinkev

@yinkev yinkev commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #439.

Summary

  • reject negative frame indices and indices equal to NumberOfFrames
  • validate before indexing the offset table or seeking into pixel data
  • document the ValueError contract on raw and decoded frame access

Root cause

The previous condition used index > number_of_frames. It therefore allowed Python negative indexing and missed the first invalid upper-bound value, index == number_of_frames.

Validation

  • regression fails on upstream/master
  • focused regression: 1 passed
  • full tests/test_io.py: 111 passed, 9 skipped
  • Flake8 on touched files
  • git diff --check

@yinkev
yinkev marked this pull request as draft July 25, 2026 20:59
@CPBridge

Copy link
Copy Markdown
Collaborator

Is this ready for review? @yinkev

@CPBridge

CPBridge commented Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

Could you please resolve the merge conflicts too (I think you just want to keep both changes)?

Signed-off-by: kyinhub <kevinpyin@gmail.com>
@yinkev
yinkev marked this pull request as ready for review July 27, 2026 21:34
@yinkev
yinkev force-pushed the bugfix/image-reader-frame-bounds branch from 3761f87 to 3b34bad Compare July 27, 2026 21:34
@yinkev

yinkev commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Good catch, leaving it as a draft was accidental. I resolved the merge conflict by keeping both changes and marked it ready for review. Thanks for catching it.

@CPBridge CPBridge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yinkev

@CPBridge
CPBridge merged commit d97a54f into ImagingDataCommons:master Jul 28, 2026
13 checks passed
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.

ImageFileReader accepts invalid frame indices

2 participants