ocsp: fix uninitialized variables in BasicResponse#status#1004
Merged
rhenium merged 1 commit intoruby:masterfrom Feb 16, 2026
Merged
Conversation
revtime, thisupd, nextupd, and reason are not initialized before being passed to OCSP_single_get0_status(). For GOOD and UNKNOWN status, OpenSSL doesn't write to revtime or reason (only REVOKED does), so they keep whatever was on the stack. The nil guard `revtime ? asn1time_to_time(revtime) : Qnil` then tries to convert a garbage pointer, which blows up with ASN1_TIME_to_tm. Initialize all four to safe defaults before the call.
3a2ab96 to
667ce07
Compare
Contributor
Author
|
Rebased to include a fix for the |
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.
BasicResponse#statusraisesOpenSSL::ASN1::ASN1Error: ASN1_TIME_to_tmfor any OCSP response with aGOODorUNKNOWNcertificate status.REVOKEDworks fine.I hit this while checking OCSP status for
google.com.Minimal reproduction:
Querying Google's OCSP responder:
Cause / fix - In
ossl_ocspbres_get_status(),revtimeis declared but not initialized before being passed toOCSP_single_get0_status():For
GOODandUNKNOWN, OpenSSL'sOCSP_single_get0_statusdoesn't write torevtime(onlyREVOKEDdoes). Sorevtimeholds whatever was on the stack, the nil guard passes, andasn1time_to_timedereferences a garbage pointer.The fix initializes all four variables before the call. Also adds test coverage for
BasicResponse#statuswithGOODandREVOKEDstatus. Previously, no tests exercised this method (existing tests useBasicResponse#responsesinstead).