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

Throw ReadOnlyBufferException if unsafe buffer is used and dst is direct #4577

Closed
wants to merge 1 commit into from

Conversation

normanmaurer
Copy link
Member

Motivation:

We missed to check if the dst is ready only before using unsafe to copy data into it which lead to data-corruption. We need to ensure we respect ready only ByteBuffer.

Modifications:

  • Correctly check if the dst is ready only before copy data into it in UnsafeByteBufUtil
  • Also make it work for buffers that are not direct and not have an array

Result:

No more data corruption possible if the dst buffer is readonly and unsafe buffer implementation is used.

@normanmaurer
Copy link
Member Author

@trustin PTAL

@normanmaurer normanmaurer self-assigned this Dec 16, 2015
@normanmaurer normanmaurer added this to the 4.0.34.Final milestone Dec 16, 2015
public void testGetReadOnlyDirectDst() {
super.testGetReadOnlyDirectDst();
}
@Test(expected = IndexOutOfBoundsException.class)
Copy link
Member

Choose a reason for hiding this comment

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

Please insert an empty line between methods.

@trustin
Copy link
Member

trustin commented Dec 17, 2015

@normanmaurer LGTM. Please cherry-pick once style comments are addressed.

Motivation:

We missed to check if the dst is ready only before using unsafe to copy data into it which lead to data-corruption. We need to ensure we respect ready only ByteBuffer.

Modifications:

- Correctly check if the dst is ready only before copy data into it in UnsafeByteBufUtil
- Also make it work for buffers that are not direct and not have an array

Result:

No more data corruption possible if the dst buffer is readonly and unsafe buffer implementation is used.
@normanmaurer
Copy link
Member Author

Cherry-picked into 4.0 (de76843) and 4.1 (4e467f5)

@normanmaurer normanmaurer deleted the unsafe_readonly_dst_corruption branch December 17, 2015 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants