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

fix/extend part number validation in MultiPart methods #1038

Merged

Conversation

peterhillman
Copy link
Contributor

Fixes #1031
Adds extra bounds checks to MultiPartInputFile and MultiPartOutputFile methods that take part indexes, and fixes an off-by-one in an existing check

Signed-off-by: Peter Hillman peterh@wetafx.co.nz

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
Copy link
Contributor

@meshula meshula left a comment

Choose a reason for hiding this comment

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

It kind of feels like we might benefit from a non-throwing bool isValidPart(int n); method and also 'void checkValidPart(int n)` that contains the throw, in order to have only one copy of the checking and reporting logic to maintain

@@ -186,6 +186,10 @@ template DeepTiledInputFile* MultiPartInputFile::getInputPart<DeepTiledInputFile
InputPartData*
MultiPartInputFile::getPart(int partNumber)
{
if(partNumber<0 || partNumber >= _data->_headers.size())
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary? Won't the call to getPart(partNumber) below check for a valid partnumber?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. That test is now removed

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
@cary-ilm cary-ilm merged commit e3d275b into AcademySoftwareFoundation:master Jun 12, 2021
cary-ilm pushed a commit to cary-ilm/openexr that referenced this pull request Jun 23, 2021
…reFoundation#1038)

* fix/extend part number validation in MultiPart methods

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>

* remove extraneous test

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
cary-ilm pushed a commit that referenced this pull request Jun 30, 2021
* fix/extend part number validation in MultiPart methods

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>

* remove extraneous test

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MultiPartInputFile::header doesn't check for out-of-bounds access
3 participants