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

fix: handle DirectByteBuffers in WolfSSLSession.read() #250

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

gasbytes
Copy link
Contributor

Fix of improper handling of DirectByteBuffers in the JNI layer. Previously, the native read() method would throw an exception when encountering a DirectByteBuffer, breaking the optimization path for single-buffer reads in WolfSSLEngine.

This change modifies the JNI implementation to properly handle both array-backed and direct ByteBuffers, maintaining the performance benefits of both buffer types while fixing the test failure.

  • Added support for DirectByteBuffers using GetDirectBufferAddress
  • Preserved existing optimization path for array-backed buffers
  • Maintained proper position updates and error handling for both types
  • Fixed SSLEngine/Arrays test without compromising performance

Copy link
Member

@cconlon cconlon left a comment

Choose a reason for hiding this comment

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

Thanks Reda, good fix! Just one small request.

native/com_wolfssl_WolfSSLSession.c Outdated Show resolved Hide resolved
@cconlon cconlon assigned gasbytes and unassigned wolfSSL-Bot Jan 10, 2025
Fix of improper handling of DirectByteBuffers in the JNI layer.
Previously, the native read() method would throw an exception when
encountering a DirectByteBuffer, breaking the optimization path for
single-buffer reads in WolfSSLEngine.

This change modifies the JNI implementation to properly handle both
array-backed and direct ByteBuffers, maintaining the performance benefits
of both buffer types while fixing the test failure.

- Added support for DirectByteBuffers using GetDirectBufferAddress
- Preserved existing optimization path for array-backed buffers
- Maintained proper position updates and error handling for both types
- Fixed SSLEngine/Arrays test without compromising performance
@cconlon cconlon merged commit e600b0f into wolfSSL:master Jan 10, 2025
45 checks passed
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.

3 participants