ext/openssl: Use zend_string_release on sigbuf in openssl_sign error path#64
Closed
iliaal wants to merge 1 commit into
Closed
ext/openssl: Use zend_string_release on sigbuf in openssl_sign error path#64iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
…path sigbuf is a zend_string allocated via zend_string_alloc. The error branch called efree(sigbuf), which happens to release the underlying memory because zend_string_alloc is currently implemented on top of emalloc, but efree is the raw-memory API and skips the refcount and interned-string checks that zend_string_release performs. The match for zend_string_alloc is zend_string_release; every other release site in this file uses that pair. Replace efree(sigbuf) with a NULL-guarded zend_string_release(). The NULL guard preserves the existing short-circuit behavior where the short-circuit fails before zend_string_alloc and sigbuf stays NULL; the release covers the path where zend_string_alloc succeeded but the following EVP_DigestSign/EVP_SignFinal failed. Existing openssl_sign_basic, openssl_sign_invalid_algorithm, and bug81713 tests exercise the NULL-sigbuf branch and continue to pass.
Owner
Author
|
Closing without promotion. Reviewed the original code more carefully: |
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.
sigbufis azend_stringallocated viazend_string_alloc. The error branch calledefree(sigbuf), which happens to release the underlying memory becausezend_string_allocis currently implemented on top ofemalloc, butefreeis the raw-memory API and skips the refcount and interned-string checks thatzend_string_releaseperforms. The match forzend_string_allociszend_string_release; every other release site in this file uses that pair.Replace
efree(sigbuf)with a NULL-guardedzend_string_release(). The NULL guard preserves the existing short-circuit behavior where the short-circuit fails beforezend_string_allocandsigbufstays NULL; the release covers the path wherezend_string_allocsucceeded but the followingEVP_DigestSign/EVP_SignFinalfailed.Existing
openssl_sign_basic,openssl_sign_invalid_algorithm, andbug81713tests exercise the NULL-sigbufbranch and continue to pass under this patch.