summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2015-04-30 21:37:06 -0400
committerRich Salz <rsalz@openssl.org>2015-04-30 21:37:06 -0400
commit23a1d5e97cd543d2b8e1b01dbf0f619b2e5ce540 (patch)
tree2d9372864fc2b34939d21b3706768ec225c9548f /apps
parent34166d41892643a36ad2d1f53cc0025e2edc2a39 (diff)
free NULL cleanup 7
This gets BN_.*free: BN_BLINDING_free BN_CTX_free BN_FLG_FREE BN_GENCB_free BN_MONT_CTX_free BN_RECP_CTX_free BN_clear_free BN_free BUF_MEM_free Also fix a call to DSA_SIG_free to ccgost engine and remove some #ifdef'd dead code in engines/e_ubsec. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'apps')
-rw-r--r--apps/apps.c3
-rw-r--r--apps/ca.c6
-rw-r--r--apps/dsaparam.c3
-rw-r--r--apps/ecparam.c18
-rw-r--r--apps/genrsa.c6
-rw-r--r--apps/s_client.c12
-rw-r--r--apps/s_server.c3
7 files changed, 18 insertions, 33 deletions
diff --git a/apps/apps.c b/apps/apps.c
index 904629b2f1..d68594ab27 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -1532,6 +1532,7 @@ int rand_serial(BIGNUM *b, ASN1_INTEGER *ai)
{
BIGNUM *btmp;
int ret = 0;
+
if (b)
btmp = b;
else
@@ -1549,7 +1550,7 @@ int rand_serial(BIGNUM *b, ASN1_INTEGER *ai)
error:
- if (!b)
+ if (btmp != b)
BN_free(btmp);
return ret;
diff --git a/apps/ca.c b/apps/ca.c
index bc7c3fd2dd..b703b425ae 100644
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1289,10 +1289,8 @@ end_of_options:
if (!save_serial(crlnumberfile, "new", crlnumber, NULL))
goto end;
- if (crlnumber) {
- BN_free(crlnumber);
- crlnumber = NULL;
- }
+ BN_free(crlnumber);
+ crlnumber = NULL;
if (!do_X509_CRL_sign(crl, pkey, dgst, sigopts))
goto end;
diff --git a/apps/dsaparam.c b/apps/dsaparam.c
index afc8a82b01..62d5fe7a41 100644
--- a/apps/dsaparam.c
+++ b/apps/dsaparam.c
@@ -328,8 +328,7 @@ int dsaparam_main(int argc, char **argv)
app_RAND_write_file(NULL);
ret = 0;
end:
- if (cb != NULL)
- BN_GENCB_free(cb);
+ BN_GENCB_free(cb);
BIO_free(in);
BIO_free_all(out);
DSA_free(dsa);
diff --git a/apps/ecparam.c b/apps/ecparam.c
index 5b39e83cd8..082df260ab 100644
--- a/apps/ecparam.c
+++ b/apps/ecparam.c
@@ -483,18 +483,12 @@ int ecparam_main(int argc, char **argv)
ret = 0;
end:
- if (ec_p)
- BN_free(ec_p);
- if (ec_a)
- BN_free(ec_a);
- if (ec_b)
- BN_free(ec_b);
- if (ec_gen)
- BN_free(ec_gen);
- if (ec_order)
- BN_free(ec_order);
- if (ec_cofactor)
- BN_free(ec_cofactor);
+ BN_free(ec_p);
+ BN_free(ec_a);
+ BN_free(ec_b);
+ BN_free(ec_gen);
+ BN_free(ec_order);
+ BN_free(ec_cofactor);
if (buffer)
OPENSSL_free(buffer);
BIO_free(in);
diff --git a/apps/genrsa.c b/apps/genrsa.c
index 7d0466aaf9..a3c00d871e 100644
--- a/apps/genrsa.c
+++ b/apps/genrsa.c
@@ -214,10 +214,8 @@ int genrsa_main(int argc, char **argv)
ret = 0;
end:
- if (bn)
- BN_free(bn);
- if (cb)
- BN_GENCB_free(cb);
+ BN_free(bn);
+ BN_GENCB_free(cb);
RSA_free(rsa);
BIO_free_all(out);
if (passout)
diff --git a/apps/s_client.c b/apps/s_client.c
index e7e66849d1..8d8340d311 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -241,8 +241,7 @@ static unsigned int psk_client_cb(SSL *ssl, const char *hint, char *identity,
if (!ret) {
BIO_printf(bio_err, "Could not convert PSK key '%s' to BIGNUM\n",
psk_key);
- if (bn)
- BN_free(bn);
+ BN_free(bn);
return 0;
}
@@ -320,12 +319,9 @@ static int srp_Verify_N_and_g(const BIGNUM *N, const BIGNUM *g)
BN_mod_exp(r, g, p, N, bn_ctx) &&
BN_add_word(r, 1) && BN_cmp(r, N) == 0;
- if (r)
- BN_free(r);
- if (p)
- BN_free(p);
- if (bn_ctx)
- BN_CTX_free(bn_ctx);
+ BN_free(r);
+ BN_free(p);
+ BN_CTX_free(bn_ctx);
return ret;
}
diff --git a/apps/s_server.c b/apps/s_server.c
index ef32d5a9b0..a616b64a11 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -315,8 +315,7 @@ static unsigned int psk_server_cb(SSL *ssl, const char *identity,
if (!ret) {
BIO_printf(bio_err, "Could not convert PSK key '%s' to BIGNUM\n",
psk_key);
- if (bn)
- BN_free(bn);
+ BN_free(bn);
return 0;
}
if (BN_num_bytes(bn) > (int)max_psk_len) {