-
Notifications
You must be signed in to change notification settings - Fork 616
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
fix/extend part number validation in MultiPart methods #1038
Conversation
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
There was a problem hiding this 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()) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
…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>
* 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>
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