From c0cc23af26d0363dbd164ceae97ed044e3fd8861 Mon Sep 17 00:00:00 2001 From: Pauli Date: Tue, 31 Jul 2018 13:11:00 +1000 Subject: [PATCH] Check return from BN_sub Reviewed-by: Tim Hudson (Merged from https://github.com/openssl/openssl/pull/6823) (cherry picked from commit 3d3cbce550ff5d6172cf28dbbf80bda93f6577a9) --- crypto/rsa/rsa_ossl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/rsa/rsa_ossl.c b/crypto/rsa/rsa_ossl.c index 41fafa7418..8e81cbb411 100644 --- a/crypto/rsa/rsa_ossl.c +++ b/crypto/rsa/rsa_ossl.c @@ -332,7 +332,8 @@ static int rsa_ossl_private_encrypt(int flen, const unsigned char *from, goto err; if (padding == RSA_X931_PADDING) { - BN_sub(f, rsa->n, ret); + if (!BN_sub(f, rsa->n, ret)) + goto err; if (BN_cmp(ret, f) > 0) res = f; else -- 2.25.1