Free every OCSP chain request in TLSX_CSR_Free - #11285
Merged
Merged
Conversation
ProcessChainOCSPRequest() stores each request at the certificate's position in the chain, counting from 1 for the first intermediate, while csr->requests is a count of successful calls. TLSX_CSR_Free() bounded the free by that count, so any entry written at an index at or above it was never released: valgrind reports the serial and URL buffers InitOcspRequest() allocated as definitely lost. Walk the whole array instead. FreeOcspRequest() is a no-op on a request that was never populated, and the array is sized MAX_CERT_EXTENSIONS.
|
Can one of the admins verify this patch? |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11285
Scan targets checked: wolfssl-bugs, wolfssl-src
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Contributor
|
Retest this please. (raise TLSAbruptCloseError() in multi-msg-record test) |
Contributor
|
note: will fix valgrind leak reported in: |
Contributor
|
Retest this please. PRB preflight hung |
philljj
approved these changes
Aug 26, 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.
Description
ProcessChainOCSPRequest()stores oneOcspRequestper certificate at thatcertificate's position in the chain:
csr->requests, however, is a count of calls that completed successfully,maintained independently of
i.TLSX_CSR_Free()bounded the release by that count:The two only coincide when index 0 was populated first. Whenever the highest
index written is at or above
csr->requests, the tail entries are neverreleased, and the serial and URL buffers
InitOcspRequest()allocated for thembecome unreachable.
Valgrind reports them as definitely lost:
This affects OCSP multi-stapling for certificate chains
(
--enable-ocspstapling). Functional behaviour is unaffected — every testpasses either way — so it only surfaces under a leak checker.
Fix: walk the whole array rather than a count.
FreeOcspRequest()is a no-opon a request that was never populated, and the array is sized
MAX_CERT_EXTENSIONS, so unpopulated slots cost nothing.Testing
Discovered through #11222
Reproducer that populates a request at chain position 1 with
csr->requestsstill 0, then frees the
WOLFSSLobject, run undervalgrind --leak-check=full:definitely lost: 43 bytes in 2 blocks,ERROR SUMMARY: 2 errorsERROR SUMMARY: 0 errorsThe 20-byte and 23-byte blocks correspond to the serial and URL allocations
in
InitOcspRequest()../tests/unit.test --group ocsp— 0 failures../wolfcrypt/test/testwolfcrypt— exit 0.Configuration used:
--enable-ocsp --enable-ocspstapling --enable-ocspstapling2 --enable-tls13