Skip to content

Check EngineHelper for null in SSLSocket.close()#283

Merged
rlm2002 merged 1 commit intowolfSSL:masterfrom
cconlon:sslSocketCloseEngineNPE
Jul 31, 2025
Merged

Check EngineHelper for null in SSLSocket.close()#283
rlm2002 merged 1 commit intowolfSSL:masterfrom
cconlon:sslSocketCloseEngineNPE

Conversation

@cconlon
Copy link
Copy Markdown
Member

@cconlon cconlon commented Jul 31, 2025

This PR adds null pointer checking to WolfSSLSocket, specifically for the issue in close() where this.EngineHelper.clearObjectState(); could have been called in some scenarios if this.EngineHelper had already been set to null.

A regression test has also been added as part of this PR.

@cconlon cconlon self-assigned this Jul 31, 2025
@cconlon cconlon requested a review from Copilot July 31, 2025 17:38
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 addresses a potential null pointer exception in the WolfSSLSocket.close() method by adding null checks for the EngineHelper field before accessing it. The fix prevents NPEs that could occur if EngineHelper was already set to null or if the constructor failed after partial initialization.

  • Added null pointer checks around EngineHelper method calls in close() and checkAndInitSSLSocket()
  • Added a regression test that simulates the scenario using reflection to set EngineHelper to null

Reviewed Changes

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

File Description
src/java/com/wolfssl/provider/jsse/WolfSSLSocket.java Added null checks for EngineHelper in close() and checkAndInitSSLSocket() methods
src/test/com/wolfssl/provider/jsse/test/WolfSSLSocketTest.java Added regression test to verify close() handles null EngineHelper without throwing NPE

Comment thread src/test/com/wolfssl/provider/jsse/test/WolfSSLSocketTest.java Outdated
Comment thread src/java/com/wolfssl/provider/jsse/WolfSSLSocket.java
@cconlon cconlon force-pushed the sslSocketCloseEngineNPE branch from d8a811d to 2289eed Compare July 31, 2025 17:45
@cconlon cconlon assigned rlm2002 and unassigned cconlon Jul 31, 2025
@rlm2002 rlm2002 merged commit 94b5198 into wolfSSL:master Jul 31, 2025
52 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