From dd5d944005166fbbfd4b72b9779f398598b3481d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sun, 8 Sep 2019 19:19:35 +0200 Subject: [PATCH] crypto: fix OpenSSL return code handling PR-URL: https://github.com/nodejs/node/pull/29489 Reviewed-By: David Carlier Reviewed-By: Ben Noordhuis Reviewed-By: Minwoo Jung Reviewed-By: James M Snell --- src/node_crypto.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 8084d935efa8e2..5761bd296e8097 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5215,7 +5215,7 @@ bool PublicKeyCipher::Cipher(Environment* env, return false; if (digest != nullptr) { - if (!EVP_PKEY_CTX_set_rsa_oaep_md(ctx.get(), digest)) + if (EVP_PKEY_CTX_set_rsa_oaep_md(ctx.get(), digest) <= 0) return false; } @@ -5223,7 +5223,8 @@ bool PublicKeyCipher::Cipher(Environment* env, // OpenSSL takes ownership of the label, so we need to create a copy. void* label = OPENSSL_memdup(oaep_label, oaep_label_len); CHECK_NOT_NULL(label); - if (!EVP_PKEY_CTX_set0_rsa_oaep_label(ctx.get(), label, oaep_label_len)) { + if (0 >= EVP_PKEY_CTX_set0_rsa_oaep_label(ctx.get(), label, + oaep_label_len)) { OPENSSL_free(label); return false; }