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

[Backport 2.4] Fix bug in SlicedInputStream with zero length #5044

Merged
merged 1 commit into from
Nov 2, 2022

Conversation

opensearch-trigger-bot[bot]
Copy link
Contributor

Backport 6571db7 from #4863.

@opensearch-trigger-bot opensearch-trigger-bot bot requested review from a team and reta as code owners November 2, 2022 17:28
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

Gradle Check (Jenkins) Run Completed with:

Per the contract of InputStream#read(byte[], int, int):

    If len is zero, then no bytes are read and 0 is returned

SlicedInputStream had a bug where if a zero length was passed then it
would drain all the underlying streams and return -1. This was uncovered
by using InputStream#readAllBytes in new code under development. The
only existing usage of SlicedInputStream should not be vulnerable to this
bug.

I've also added a check for invalid arguments and created tests to
ensure the proper exceptions are thrown per the InputStream contract. In
the test I've replaced a "readFully" method with an equivalent
"readNBytes" that was introduced in Java 11.

Signed-off-by: Andrew Ross <[email protected]>

Signed-off-by: Andrew Ross <[email protected]>
(cherry picked from commit 6571db7)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Andrew Ross <[email protected]>
@andrross andrross force-pushed the backport/backport-4863-to-2.4 branch from 2ce0f0a to 666f4fe Compare November 2, 2022 18:33
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

Gradle Check (Jenkins) Run Completed with:

@andrross
Copy link
Member

andrross commented Nov 2, 2022

#5030

@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2022

Gradle Check (Jenkins) Run Completed with:

@andrross andrross merged commit 870d13d into 2.4 Nov 2, 2022
@github-actions github-actions bot deleted the backport/backport-4863-to-2.4 branch November 2, 2022 22:00
tlfeng pushed a commit to tlfeng/OpenSearch that referenced this pull request Nov 3, 2022
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.

1 participant