From 5d6f1bc415693577497690afe867dc2938b3dd88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Mon, 14 Mar 2022 15:23:14 +0100 Subject: [PATCH] src: check return value of HMAC_Final PR-URL: https://github.com/nodejs/node/pull/42303 Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Darshan Sen --- src/crypto/crypto_hmac.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/crypto/crypto_hmac.cc b/src/crypto/crypto_hmac.cc index 38503ac8ac33d4..d6a652ff8f5ee0 100644 --- a/src/crypto/crypto_hmac.cc +++ b/src/crypto/crypto_hmac.cc @@ -124,8 +124,11 @@ void Hmac::HmacDigest(const FunctionCallbackInfo& args) { unsigned int md_len = 0; if (hmac->ctx_) { - HMAC_Final(hmac->ctx_.get(), md_value, &md_len); + bool ok = HMAC_Final(hmac->ctx_.get(), md_value, &md_len); hmac->ctx_.reset(); + if (!ok) { + return ThrowCryptoError(env, ERR_get_error(), "Failed to finalize HMAC"); + } } Local error;