Skip to content

Add a null check to OCSP stapling - #12951

Merged
maskit merged 3 commits into
apache:masterfrom
maskit:ocsp_defencive_code1
Mar 10, 2026
Merged

Add a null check to OCSP stapling#12951
maskit merged 3 commits into
apache:masterfrom
maskit:ocsp_defencive_code1

Conversation

@maskit

@maskit maskit commented Mar 10, 2026

Copy link
Copy Markdown
Member

Code analysis found that the returned value is not checked before the memcpy.

Code analyzation found that the returned value is not checked before the memcpy.
@maskit maskit added this to the 11.0.0 milestone Mar 10, 2026
@maskit maskit self-assigned this Mar 10, 2026
@maskit maskit added the TLS label Mar 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds a null pointer check for the return value of OPENSSL_malloc() in the ssl_callback_ocsp_stapling function in OCSPStapling.cc. Previously, if OPENSSL_malloc failed (returned nullptr), the code would proceed to call memcpy with a null destination pointer, causing undefined behavior (likely a crash). The fix correctly releases the mutex and returns SSL_TLSEXT_ERR_NOACK when allocation fails.

Changes:

  • Added a null check for the OPENSSL_malloc return value before the memcpy call.
  • On allocation failure, the stapling mutex is released and the function returns SSL_TLSEXT_ERR_NOACK (graceful degradation — the handshake continues without OCSP stapling).

Comment thread src/iocore/net/OCSPStapling.cc
@maskit
maskit requested a review from Copilot March 10, 2026 17:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/iocore/net/OCSPStapling.cc
@bneradt

bneradt commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

[approve ci autest 0]

@maskit
maskit merged commit 3771467 into apache:master Mar 10, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this to For v10.2.0 in ATS v10.2.x Mar 10, 2026
@cmcfarlen cmcfarlen moved this from For v10.2.0 to Picked v10.2.0 in ATS v10.2.x Mar 18, 2026
@cmcfarlen cmcfarlen modified the milestones: 11.0.0, 10.2.0 Mar 18, 2026
@cmcfarlen

Copy link
Copy Markdown
Contributor

Cherry-picked to 10.2.x

cmcfarlen pushed a commit that referenced this pull request Mar 18, 2026
* Add a null check to OCSP stapling

Code analyzation found that the returned value is not checked before the memcpy.

* Add debug log

* Change the debug log to an error log

(cherry picked from commit 3771467)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Picked v10.2.0

Development

Successfully merging this pull request may close these issues.

4 participants