src: check return value of HMAC_Final

PR-URL: https://github.com/nodejs/node/pull/42303
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
Tobias Nießen 2022-03-14 15:23:14 +01:00 committed by GitHub
parent 7612fc3ec6
commit a718ef91f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -124,8 +124,11 @@ void Hmac::HmacDigest(const FunctionCallbackInfo<Value>& 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<Value> error;