Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size overflow for large images #7664

Closed
rdengate opened this issue Aug 24, 2023 · 2 comments · Fixed by #7677
Closed

Size overflow for large images #7664

rdengate opened this issue Aug 24, 2023 · 2 comments · Fixed by #7677
Assignees
Milestone

Comments

@rdengate
Copy link

rdengate commented Aug 24, 2023

Imagine you have an inr file with dimensions 1500 x 1500 x 1500, which you are trying to read in, for mesh generation.

In ImageIO_impl.h, from line 1245, we have:

unsigned long size, nread;

if(im->openMode != OM_CLOSE) {
    size = im->xdim * im->ydim * im->zdim * im->vdim * im->wdim;

Let's say vdim is 1 and wdim is 2. Size should then be 6,750,000,000, but anything over 4,294,967,295 overflows. When the wrong value for size is used, the image is not read in correctly, which later results in an access violation exception.

If size_t (unsigned long long) is used for size instead of unsigned long, the value of size is stored correctly.

I propose changing this (in three places) in ImageIO_impl. If this is an acceptable solution, I'm happy to lodge a pull request.

@lrineau
Copy link
Member

lrineau commented Aug 28, 2023

You are right. We would welcome a pull-request on that issue. Thanks @rdengate

@rdengate
Copy link
Author

Thanks @lrineau. I have created a pull request, please see #7677.

@lrineau lrineau linked a pull request Aug 29, 2023 that will close this issue
@lrineau lrineau added this to the 5.6.1 milestone Aug 29, 2023
@lrineau lrineau closed this as completed Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants