Skip to content

fix/extend part number validation in MultiPart methods - #1038

Merged
cary-ilm merged 2 commits into
AcademySoftwareFoundation:masterfrom
peterhillman:validate_part_indexes
Jun 12, 2021
Merged

cary-ilm merged 2 commits into
AcademySoftwareFoundation:masterfrom
peterhillman:validate_part_indexes

Conversation

@peterhillman

Copy link
Copy Markdown
Collaborator

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>

@meshula meshula left a comment

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.

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

InputPartData*
MultiPartInputFile::getPart(int partNumber)
{
if(partNumber<0 || partNumber >= _data->_headers.size())

Copy link
Copy Markdown
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
Copy Markdown
Collaborator 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