Fix |BN_CTX_get| error checking in |BN_from_montgomery|.
In the case |BN_CTX_get| failed, the function returned without calling |BN_CTX_end|. Fix that. Change-Id: Ia24cba3256e2cec106b539324e9679d690048780 Reviewed-on: https://boringssl-review.googlesource.com/7592 Reviewed-by: David Benjamin <davidben@google.com>
This commit is contained in:
parent
9d354693ff
commit
44477c03b9
@ -410,23 +410,24 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, const BN_MONT_CTX *mont,
|
||||
int BN_from_montgomery(BIGNUM *r, const BIGNUM *a, const BN_MONT_CTX *mont,
|
||||
BN_CTX *ctx) {
|
||||
int retn = 0;
|
||||
int ret = 0;
|
||||
BIGNUM *t;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
t = BN_CTX_get(ctx);
|
||||
if (t == NULL) {
|
||||
return 0;
|
||||
if (t == NULL ||
|
||||
!BN_copy(t, a)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (BN_copy(t, a)) {
|
||||
retn = BN_from_montgomery_word(ret, t, mont);
|
||||
}
|
||||
ret = BN_from_montgomery_word(r, t, mont);
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
|
||||
return retn;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
|
Loading…
Reference in New Issue
Block a user