Skip to content

Fix off-by-one error when checking fileSizeMax in FileItemInputImpl#235

Merged
garydgregory merged 1 commit intoapache:masterfrom
weavejester:file-size-max-bugfix
Aug 15, 2023
Merged

Fix off-by-one error when checking fileSizeMax in FileItemInputImpl#235
garydgregory merged 1 commit intoapache:masterfrom
weavejester:file-size-max-bugfix

Conversation

@weavejester
Copy link
Contributor

The onMaxLength method of BoundedInputStream triggers when the maxLength is met or exceeded, and we want to throw an exception only when it is exceeded. To fix this, the fileSizeMax attribute is incremented before being passed to the bounded stream.

I've added tests to check the cases where the fileSizeMax equals the length of the stream, and where the length of the stream is one greater. Let me know if I need to file a JIRA issue to go along with this.

@garydgregory garydgregory merged commit 90ced38 into apache:master Aug 15, 2023
@garydgregory garydgregory changed the title Fix off-by-one error when checking fileSizeMax Fix off-by-one error when checking fileSizeMax in FileItemInputImpl Aug 15, 2023
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