diff options
author | uqs <uqs@FreeBSD.org> | 2010-12-20 19:07:56 +0000 |
---|---|---|
committer | uqs <uqs@FreeBSD.org> | 2010-12-20 19:07:56 +0000 |
commit | 755da7b81e44c6efd747c9496468f0f255556ad5 (patch) | |
tree | fde41636748ddcd04bd6d166f40582066d8cc9f7 /games | |
parent | 30fb15bb2d08648d1ce2e70d38c6ebe53d7e9759 (diff) | |
download | FreeBSD-src-755da7b81e44c6efd747c9496468f0f255556ad5.zip FreeBSD-src-755da7b81e44c6efd747c9496468f0f255556ad5.tar.gz |
factor(6): Check return values of BN_* functions.
Coverity Prevent: CID 4862, 8771, 8772, 8773
Diffstat (limited to 'games')
-rw-r--r-- | games/factor/factor.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/games/factor/factor.c b/games/factor/factor.c index 1444d0b..d1c69a7 100644 --- a/games/factor/factor.c +++ b/games/factor/factor.c @@ -211,7 +211,8 @@ pr_fact(BIGNUM *val) bnfact = BN_new(); BN_set_word(bnfact, *(fact - 1)); - BN_sqr(bnfact, bnfact, ctx); + if (!BN_sqr(bnfact, bnfact, ctx)) + errx(1, "error in BN_sqr()"); if (BN_cmp(bnfact, val) > 0 || BN_is_prime(val, PRIME_CHECKS, NULL, NULL, NULL) == 1) @@ -271,7 +272,8 @@ pollard_pminus1(BIGNUM *val) BN_set_word(rbase, 1); newbase: - BN_add_word(rbase, 1); + if (!BN_add_word(rbase, 1)) + errx(1, "error in BN_add_word()"); BN_set_word(i, 2); BN_copy(base, rbase); @@ -282,7 +284,8 @@ newbase: BN_copy(x, base); BN_sub_word(x, 1); - BN_gcd(x, x, val, ctx); + if (!BN_gcd(x, x, val, ctx)) + errx(1, "error in BN_gcd()"); if (!BN_is_one(x)) { if (BN_is_prime(x, PRIME_CHECKS, NULL, NULL, @@ -303,7 +306,8 @@ newbase: } BN_copy(val, num); } - BN_add_word(i, 1); + if (!BN_add_word(i, 1)) + errx(1, "error in BN_add_word()"); } } |