Skip to content

dicom: enforce reasonable resolution limits to guard against corrupt file#5167

Merged
lgritz merged 1 commit intoAcademySoftwareFoundation:mainfrom
lgritz:lg-dicomcheck
May 5, 2026
Merged

dicom: enforce reasonable resolution limits to guard against corrupt file#5167
lgritz merged 1 commit intoAcademySoftwareFoundation:mainfrom
lgritz:lg-dicomcheck

Conversation

@lgritz
Copy link
Copy Markdown
Collaborator

@lgritz lgritz commented Apr 28, 2026

No description provided.

…files

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz
Copy link
Copy Markdown
Collaborator Author

lgritz commented May 4, 2026

Any comments on this one?

Copy link
Copy Markdown
Contributor

@jessey-git jessey-git left a comment

Choose a reason for hiding this comment

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

Seems alright given my comment below.


m_spec = ImageSpec(m_img->getWidth(), m_img->getHeight(), nchannels,
format);
if (!check_open(m_spec, { 0, 1 << 20, 0, 1 << 20, 0, 1 << 16, 0, 1 << 16 }))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's a very big image... 62bits required if utilizing the entire space there :) I wasn't able to find the format limits going through their docs but this seems reasonable until we're told otherwise.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These are the limits on individual dimensions. There's a separate limit on the total (w x h x d x chans x channelsize). It won't really allocate for a 1M x 1M image unless the app raises that limit via an attribute, but why not let it do 1M x 16? DICOM is for scientific and medical data, so it may have weirder shapes than the kinds of images that we generally use.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, still protected by "imagesize_MB" setting, it was just a general "Wow that would be a big image, I hope the doc never needs something like that for me."

@lgritz lgritz merged commit a11ee11 into AcademySoftwareFoundation:main May 5, 2026
30 checks passed
@lgritz lgritz deleted the lg-dicomcheck branch May 5, 2026 21:20
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.

2 participants