Skip to content

Correct call to CallObjectMethod() in WolfSSLSession ByteBuffer read()#286

Merged
rlm2002 merged 1 commit intowolfSSL:masterfrom
cconlon:sslSessionBBSetPositionFix
Sep 18, 2025
Merged

Correct call to CallObjectMethod() in WolfSSLSession ByteBuffer read()#286
rlm2002 merged 1 commit intowolfSSL:masterfrom
cconlon:sslSessionBBSetPositionFix

Conversation

@cconlon
Copy link
Copy Markdown
Member

@cconlon cconlon commented Sep 17, 2025

This PR fixes one JNI call in com.wolfssl.WolfSSLSession.read(ByteBuffer data, int sz, int timeout) where the JNI code was calling CallVoidMethod() but should be calling CallObjectMethod().

This worked on most JDK versions, but showed up on Android similar to the following:

[wolfJSSE INFO: TID 1073: WolfSSLSocket$WolfSSLInputStream] ssl.read() socket timeout = 0
JNI DETECTED ERROR IN APPLICATION: the return type of CallVoidMethod does not match java.nio.Buffer java.nio.ByteBuffer.position(int)
    in call to CallVoidMethod
    from int com.wolfssl.WolfSSLSession.read(long, java.nio.ByteBuffer, int, int, boolean, int, int)

@cconlon cconlon self-assigned this Sep 17, 2025
@cconlon cconlon requested a review from Copilot September 17, 2025 20:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a JNI method call bug in the WolfSSLSession ByteBuffer read functionality where CallVoidMethod() was incorrectly used instead of CallObjectMethod() when calling the ByteBuffer's position() method.

  • Corrects JNI method call from CallVoidMethod() to CallObjectMethod() for ByteBuffer.position()
  • Adds comprehensive test coverage for ByteBuffer read functionality

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
native/com_wolfssl_WolfSSLSession.c Fixes incorrect JNI method call type for ByteBuffer.position()
src/test/com/wolfssl/test/WolfSSLSessionTest.java Adds new test method to verify ByteBuffer read functionality and position updates

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/test/com/wolfssl/test/WolfSSLSessionTest.java Outdated
@cconlon cconlon force-pushed the sslSessionBBSetPositionFix branch from 1fb0bbd to 05414b4 Compare September 17, 2025 20:58
@cconlon cconlon assigned rlm2002 and unassigned cconlon Sep 17, 2025
@rlm2002 rlm2002 merged commit be1ec83 into wolfSSL:master Sep 18, 2025
55 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