Skip to content

Commit 1c20b3a

Browse files
tniessenxtx1130
authored andcommitted
src: check return value of HMAC_Final
PR-URL: nodejs#42303 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent d4eeb10 commit 1c20b3a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/crypto/crypto_hmac.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ void Hmac::HmacDigest(const FunctionCallbackInfo<Value>& args) {
124124
unsigned int md_len = 0;
125125

126126
if (hmac->ctx_) {
127-
HMAC_Final(hmac->ctx_.get(), md_value, &md_len);
127+
bool ok = HMAC_Final(hmac->ctx_.get(), md_value, &md_len);
128128
hmac->ctx_.reset();
129+
if (!ok) {
130+
return ThrowCryptoError(env, ERR_get_error(), "Failed to finalize HMAC");
131+
}
129132
}
130133

131134
Local<Value> error;

0 commit comments

Comments
 (0)