summaryrefslogtreecommitdiffstats
path: root/apps/gendsa.c
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-03-19 10:23:12 +1000
committerPauli <pauli@openssl.org>2021-03-26 08:44:04 +1000
commit26d5244253f94b6bd0fa41d4a222c827d8c5b3fe (patch)
tree475abe89404d565244f7326607203946188502fe /apps/gendsa.c
parentfbe286a36efffacc846c9134c4f000f2a49355a0 (diff)
apps: fix coverity 1470781: explicit null dereference
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14618)
Diffstat (limited to 'apps/gendsa.c')
-rw-r--r--apps/gendsa.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/apps/gendsa.c b/apps/gendsa.c
index 13ac69d37d..482191d8bf 100644
--- a/apps/gendsa.c
+++ b/apps/gendsa.c
@@ -60,8 +60,7 @@ int gendsa_main(int argc, char **argv)
char *dsaparams = NULL, *ciphername = NULL;
char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
OPTION_CHOICE o;
- int ret = 1, private = 0, verbose = 0;
- const BIGNUM *p = NULL;
+ int ret = 1, private = 0, verbose = 0, nbits;
prog = opt_init(argc, argv, gendsa_options);
while ((o = opt_next()) != OPT_EOF) {
@@ -126,7 +125,8 @@ int gendsa_main(int argc, char **argv)
if (out == NULL)
goto end2;
- if (EVP_PKEY_bits(pkey) > OPENSSL_DSA_MAX_MODULUS_BITS)
+ nbits = EVP_PKEY_bits(pkey);
+ if (nbits > OPENSSL_DSA_MAX_MODULUS_BITS)
BIO_printf(bio_err,
"Warning: It is not recommended to use more than %d bit for DSA keys.\n"
" Your key size is %d! Larger key size may behave not as expected.\n",
@@ -144,7 +144,7 @@ int gendsa_main(int argc, char **argv)
goto end;
}
if (verbose)
- BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
+ BIO_printf(bio_err, "Generating DSA key, %d bits\n", nbits);
if (EVP_PKEY_keygen(ctx, &pkey) <= 0) {
BIO_printf(bio_err, "unable to generate key\n");
goto end;