crypto,quic: add NULL checks for OpenSSL allocation functions#63040
Open
armorbreak001 wants to merge 1 commit intonodejs:mainfrom
Open
crypto,quic: add NULL checks for OpenSSL allocation functions#63040armorbreak001 wants to merge 1 commit intonodejs:mainfrom
armorbreak001 wants to merge 1 commit intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
Replace CHECK() assertions with graceful error handling for EVP_CIPHER_CTX_new() allocation failures. - src/crypto/crypto_aes.cc: In AES_Cipher(), replace CHECK(ctx) with early return of WebCryptoCipherStatus::FAILED, matching the pattern already used in AES_CTR_Cipher2() in the same file. - src/crypto/crypto_cipher.cc: In CipherBase::CommonInit(), replace CHECK(ctx_) with ThrowCryptoError(), matching the error handling pattern used elsewhere in the function. Note: The other locations mentioned in nodejs#62774 (AES_CTR_Cipher2, TLSSession::Initialize, and ECKeyExportTraits::DoExport) already have proper NULL checks in the current codebase or have been refactored such that the relevant code no longer exists. Fixes: nodejs#62774
234ce29 to
78ab09a
Compare
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.
Fixes: #62774
This PR adds graceful NULL checks for OpenSSL allocation function return values, replacing
CHECK()assertions that would abort the process on allocation failure.Changes
src/crypto/crypto_aes.cc—AES_Cipher()Replaced
CHECK(ctx)with:This matches the pattern already used in
AES_CTR_Cipher2()in the same file.src/crypto/crypto_cipher.cc—CipherBase::CommonInit()Replaced
CHECK(ctx_)with:This matches the error handling pattern used elsewhere in the same function.
Note on other locations from #62774
AES_CTR_Cipher2()— Already has a properif (!ctx)check (line 238)TLSSession::Initialize()— Already has a properif (!ssl)check (line 794)ECKeyExportTraits::DoExport()— This function no longer exists in the current codebase; the EC key handling code has been refactored