diff options
author | David Benjamin <davidben@chromium.org> | 2015-02-16 11:57:55 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-02-17 23:55:56 +0300 |
commit | 9d0847ae6dc2a54f2c673e82fe4ede2570923710 (patch) | |
tree | 74321452f10da4fc44bb923a2e20d5216c717c1d /crypto | |
parent | ed7c4751542d81f86161fd1c3598c189fc976f58 (diff) |
Add some missing error failure checks.
Found while diagnosing some crashes and hangs in the malloc tests. This (and
the follow-up) get us further but does not quite let the malloc tests pass
quietly, even without valgrind. DTLS silently ignores some malloc failures
(confusion with silently dropping bad packets) which then translate to hangs.
Change-Id: Ief06a671e0973d09d2883432b89a86259e346653
Reviewed-on: https://boringssl-review.googlesource.com/3482
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bn/div.c | 4 | ||||
-rw-r--r-- | crypto/bn/gcd.c | 12 |
2 files changed, 5 insertions, 11 deletions
diff --git a/crypto/bn/div.c b/crypto/bn/div.c index 2bf86de7..8b0152e8 100644 --- a/crypto/bn/div.c +++ b/crypto/bn/div.c @@ -362,7 +362,9 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, * BN_rshift() will overwrite it. */ int neg = num->neg; - BN_rshift(rm, snum, norm_shift); + if (!BN_rshift(rm, snum, norm_shift)) { + goto err; + } if (!BN_is_zero(rm)) { rm->neg = neg; } diff --git a/crypto/bn/gcd.c b/crypto/bn/gcd.c index 789a0942..3132c29e 100644 --- a/crypto/bn/gcd.c +++ b/crypto/bn/gcd.c @@ -258,12 +258,8 @@ BIGNUM *BN_mod_inverse(BIGNUM *out, const BIGNUM *a, const BIGNUM *n, goto err; } - BN_one(X); BN_zero(Y); - if (BN_copy(B, a) == NULL) { - goto err; - } - if (BN_copy(A, n) == NULL) { + if (!BN_one(X) || BN_copy(B, a) == NULL || BN_copy(A, n) == NULL) { goto err; } A->neg = 0; @@ -570,12 +566,8 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *out, const BIGNUM *a, goto err; } - BN_one(X); BN_zero(Y); - if (BN_copy(B, a) == NULL) { - goto err; - } - if (BN_copy(A, n) == NULL) { + if (!BN_one(X) || BN_copy(B, a) == NULL || BN_copy(A, n) == NULL) { goto err; } A->neg = 0; |