Skip to content

Disallow matching URI type in CheckForAltNames. NULL *response on error in wolfSSL_d2i_OCSP_RESPONSE.#10509

Open
kareem-wolfssl wants to merge 3 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd21863_5
Open

Disallow matching URI type in CheckForAltNames. NULL *response on error in wolfSSL_d2i_OCSP_RESPONSE.#10509
kareem-wolfssl wants to merge 3 commits into
wolfSSL:masterfrom
kareem-wolfssl:zd21863_5

Conversation

@kareem-wolfssl
Copy link
Copy Markdown
Contributor

Description

Fixes zd#21863, zd#21865

Testing

Built in tests, provided reproducers

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Thanks to Haruki Oyama (Waseda University) for the report.
Thanks to Zou Dikai for the report.
@kareem-wolfssl kareem-wolfssl self-assigned this May 20, 2026
Copilot AI review requested due to automatic review settings May 20, 2026 23:34
Copy link
Copy Markdown
Contributor

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 two certificate/OCSP edge cases: (1) TLS hostname matching should not treat URI SANs as DNSName SANs, and (2) wolfSSL_d2i_OCSP_RESPONSE() should NULL out a caller-supplied *response on failure to avoid leaving a dangling pointer.

Changes:

  • Update CheckForAltNames() to skip uniformResourceIdentifier SANs when performing DNS hostname checks.
  • Update wolfSSL_d2i_OCSP_RESPONSE() error paths to clear *response when the caller passed a reusable response pointer.
  • Add regression tests covering URI SAN hostname-matching behavior and OCSP response reuse failure semantics.

Reviewed changes

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

Show a summary per file
File Description
wolfcrypt/src/asn.c Updates in-code documentation clarifying URI SAN handling vs CN fallback behavior.
src/internal.c Skips URI SAN entries during DNS hostname matching in CheckForAltNames().
src/ocsp.c Clears caller’s *response on allocation/decode failures in wolfSSL_d2i_OCSP_RESPONSE().
tests/api/test_ocsp.c Adds a test to ensure *response is NULLed on reuse + decode failure.
tests/api/test_certman.h Registers a new certman API test.
tests/api/test_certman.c Adds a test ensuring URI SANs don’t satisfy DNS hostname checks (and validates behavior when DNS SAN is also present).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ocsp.c
Comment on lines 1276 to 1292
if (response != NULL)
resp = *response;
if (resp == NULL) {
resp = (OcspResponse*)XMALLOC(sizeof(OcspResponse), NULL,
DYNAMIC_TYPE_OCSP_REQUEST);
if (resp == NULL)
return NULL;
XMEMSET(resp, 0, sizeof(OcspResponse));
}

resp->source = (byte*)XMALLOC((size_t)len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (resp->source == NULL) {
XFREE(resp, NULL, DYNAMIC_TYPE_OCSP_REQUEST);
if (response != NULL && *response == resp)
*response = NULL;
return NULL;
}
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

MemBrowse Memory Report

No memory changes detected for:

@haruki0409
Copy link
Copy Markdown

The changes look good. Thank you for the prompt response.

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.

4 participants