diff options
author | Matt Caswell <matt@openssl.org> | 2015-08-10 13:00:29 +0200 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-08-11 20:57:01 +0200 |
commit | 6a009812b2e249fed01488f6f19f9fbfd9ee74c4 (patch) | |
tree | 56bd838e9d50be78716dd2437fbb2682b8fa98ee /crypto/bn | |
parent | Fix seg fault with 0 p val in SKE (diff) | |
download | openssl-6a009812b2e249fed01488f6f19f9fbfd9ee74c4.tar.xz openssl-6a009812b2e249fed01488f6f19f9fbfd9ee74c4.zip |
Check for 0 modulus in BN_MONT_CTX_set
The function BN_MONT_CTX_set was assuming that the modulus was non-zero
and therefore that |mod->top| > 0. In an error situation that may not be
the case and could cause a seg fault.
This is a follow on from CVE-2015-1794.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/bn_mont.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c index 1580e978ce..d4d817a74f 100644 --- a/crypto/bn/bn_mont.c +++ b/crypto/bn/bn_mont.c @@ -351,6 +351,9 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) int ret = 0; BIGNUM *Ri, *R; + if (BN_is_zero(mod)) + return 0; + BN_CTX_start(ctx); if ((Ri = BN_CTX_get(ctx)) == NULL) goto err; |