Repository navigation
Fix: F-7523 - #11937
Draft
ohki-saito wants to merge 2 commits into
Draft
Fix: F-7523#11937ohki-saito wants to merge 2 commits into
ohki-saito wants to merge 2 commits into
Conversation
|
Can one of the admins verify this patch? |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The OCSP regression test references allocator callbacks and failure flags outside their configuration guards, causing compilation failures when WOLFSSL_STATIC_MEMORY or WOLFSSL_NO_MALLOC is defined, or USE_WOLFSSL_MEMORY is absent.
1 open issue
What changed in this PR
Addresses F-7523 in wolfSSL’s OCSP compatibility API by preserving request state and caller ownership when serial-buffer allocation fails, preventing a double free.
Changes:
- Allocates the replacement serial buffer before modifying the request.
- Uses the matching allocation type when freeing the old serial buffer.
- Adds an allocation-failure regression test for ownership and cleanup.
| File | Description |
|---|---|
tests/api.c |
Adds allocator fault injection and checks failed-call state and cleanup. |
src/ocsp.c |
Makes serial allocation failure leave the request unchanged and corrects the free allocation type. |
Review effort: Balanced
Comment on lines
+27933
to
+27934
| ExpectIntEQ(wolfSSL_SetAllocators(ocsp_oom_malloc_cb, ocsp_oom_free_cb, | ||
| ocsp_oom_realloc_cb), 0); |
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.

Description
Fenrir Finding F-7523
wolfSSL_OCSP_request_add0_id()freed the previousreq->cid, stored the newcidinreq, and overwroteissuerHash/issuerKeyHash/hashAlgbefore allocating the serial buffer. If that allocation failed, the function returned NULL withreqpartly updated and already holdingcid. A caller following add0 semantics freescidafter a failed call, sowolfSSL_OCSP_REQUEST_free()later freed it again.Changes:
req. On failure,reqis unchanged and the caller still ownscid.req->serialwithDYNAMIC_TYPE_OCSP_REQUEST, matching how it is allocated.Testing
Added a test using a custom allocator that fails the serial allocation in
OCSP_request_add0_id(). It checks that the call returns NULL, thatreqhas nocidand no serial afterwards, and that freeingcidandreqseparately does not double free.Checklist