aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-04-15 14:31:03 +0100
committerMatt Caswell <matt@openssl.org>2016-04-21 10:51:57 +0100
commite69f2a223cf7e2d7f5bcea43e68ce38818813b81 (patch)
tree69772b59af4c232a6550fb39d231dcb295bf898c
parent46da5f9ca98822197f09b74248f1b9cc60ad3307 (diff)
downloadopenssl-e69f2a223cf7e2d7f5bcea43e68ce38818813b81.tar.gz
Add missing return value checks
Also correct the return value from the the "prime" application Reviewed-by: Richard Levitte <levitte@openssl.org>
-rw-r--r--apps/prime.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/apps/prime.c b/apps/prime.c
index b18257de7e..3cbf98d4e6 100644
--- a/apps/prime.c
+++ b/apps/prime.c
@@ -122,16 +122,26 @@ int prime_main(int argc, char **argv)
goto end;
}
bn = BN_new();
- BN_generate_prime_ex(bn, bits, safe, NULL, NULL, NULL);
+ if (!BN_generate_prime_ex(bn, bits, safe, NULL, NULL, NULL)) {
+ BIO_printf(bio_err, "Failed to generate prime.\n");
+ goto end;
+ }
s = hex ? BN_bn2hex(bn) : BN_bn2dec(bn);
BIO_printf(bio_out, "%s\n", s);
OPENSSL_free(s);
} else {
for ( ; *argv; argv++) {
+ int r;
+
if (hex)
- BN_hex2bn(&bn, argv[0]);
+ r = BN_hex2bn(&bn, argv[0]);
else
- BN_dec2bn(&bn, argv[0]);
+ r = BN_dec2bn(&bn, argv[0]);
+
+ if(!r) {
+ BIO_printf(bio_err, "Failed to process value (%s)\n", argv[0]);
+ goto end;
+ }
BN_print(bio_out, bn);
BIO_printf(bio_out, " (%s) %s prime\n",
@@ -143,6 +153,7 @@ int prime_main(int argc, char **argv)
BN_free(bn);
+ ret = 0;
end:
return ret;
}