WolfSSLEngine ByteBuffer offset/bounds fixes and JNI arrayOffset honoring#360
Merged
cconlon merged 7 commits intowolfSSL:masterfrom Apr 29, 2026
Merged
WolfSSLEngine ByteBuffer offset/bounds fixes and JNI arrayOffset honoring#360cconlon merged 7 commits intowolfSSL:masterfrom
cconlon merged 7 commits intowolfSSL:masterfrom
Conversation
edc0c2b to
d10ee29
Compare
d10ee29 to
90316b6
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #360
Scan targets checked: wolfssljni-bugs, wolfssljni-src
No new issues found in the changed files. ✅
There was a problem hiding this comment.
Pull request overview
Fixes several SSLEngine/WolfSSLSession ByteBuffer offset/bounds issues (including JNI honoring ByteBuffer.arrayOffset()), and adds regression tests to prevent reintroduction.
Changes:
- Fix
WolfSSLEnginebuffer-array offset handling (pos/limit indexing) and correct wrap/unwrap argument-validation loop bounds. - Ensure
closeOutbound()pre-handshake also closes inbound soisInboundDone()reflects completion. - Update JNI ByteBuffer read/write paths to honor
ByteBuffer.arrayOffset()for sliced/duplicated heap buffers, plus add regression tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/java/com/wolfssl/provider/jsse/WolfSSLEngine.java | Fixes offset indexing/OOB issues in wrap/unwrap and SendAppData; adjusts pre-handshake closeOutbound inbound state. |
| native/com_wolfssl_globals.h | Adds cached JNI method ID declaration for ByteBuffer.arrayOffset(). |
| native/com_wolfssl_WolfSSL.c | Caches ByteBuffer.arrayOffset() method ID during JNI_OnLoad and clears it on unload. |
| native/com_wolfssl_WolfSSLSession.c | Applies arrayOffset + position when reading/writing array-backed ByteBuffers in JNI. |
| src/test/com/wolfssl/test/WolfSSLSessionTest.java | Adds regression test ensuring read(ByteBuffer) honors arrayOffset() for sliced heap buffers. |
| src/test/com/wolfssl/provider/jsse/test/WolfSSLEngineTest.java | Adds regression tests for closeOutbound pre-handshake and wrap/unwrap buffer-array offset validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
90316b6 to
56810a8
Compare
cconlon
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes F-3487, F-3488, F-3489, F-3490, F-3492
Added regression tests