Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Dec 2010 19:07:56 +0000 (UTC)
From:      Ulrich Spoerlein <uqs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r216598 - head/games/factor
Message-ID:  <201012201907.oBKJ7uuc077160@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: uqs
Date: Mon Dec 20 19:07:56 2010
New Revision: 216598
URL: http://svn.freebsd.org/changeset/base/216598

Log:
  factor(6): Check return values of BN_* functions.
  
  Coverity Prevent:	CID 4862, 8771, 8772, 8773

Modified:
  head/games/factor/factor.c

Modified: head/games/factor/factor.c
==============================================================================
--- head/games/factor/factor.c	Mon Dec 20 19:07:48 2010	(r216597)
+++ head/games/factor/factor.c	Mon Dec 20 19:07:56 2010	(r216598)
@@ -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()");
 	}
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012201907.oBKJ7uuc077160>