crypto: fix unhandled error in Hash._transform#63261
Open
haramj wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
Signed-off-by: haramjeong <04harams77@gmail.com>
868c0c8 to
931b4bc
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #63261 +/- ##
==========================================
- Coverage 90.04% 90.04% -0.01%
==========================================
Files 713 713
Lines 225003 225004 +1
Branches 42536 42539 +3
==========================================
- Hits 202606 202603 -3
- Misses 14177 14183 +6
+ Partials 8220 8218 -2
🚀 New features to boost your workflow:
|
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
This PR fixes a bug where errors occurring during
Hash.prototype.write()were silently swallowed instead of being surfaced.Problem
In
lib/internal/crypto/hash.js, the_transformimplementation did not check the return value ofthis[kHandle].update(). While the synchronousupdate()method correctly throwsERR_CRYPTO_HASH_UPDATE_FAILEDon failure, the streaming interface continued execution even if the underlying ncrypto binding returnedfalse. This resulted in incorrect hash outputs without any error notification to the user.Solution
Updated
Hash.prototype._transformto check the return value of the internalupdate()call. If it returnsfalse, the error is passed to the stream callback, triggering an'error'event as expected for astream.Transforminstance.Validation
test/parallel/test-crypto-hash-stream-error.js.kHandleto simulate anupdatefailure and verifies that an'error'event withERR_CRYPTO_HASH_UPDATE_FAILEDis emitted.test/parallel/test-crypto-hash.js) still pass.Checklist
make lint-jspassesmake test-parallel(relevant to crypto) passesFixes: #63258