summaryrefslogtreecommitdiffstats
path: root/apps/ca.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2001-08-17 01:09:54 +0000
committerDr. Stephen Henson <steve@openssl.org>2001-08-17 01:09:54 +0000
commitb65f851318ae22739928457037d20d89d131d38e (patch)
tree9ceae1e7471a69b5b9a35029024376f600b7ee1d /apps/ca.c
parent35bf35411c332fcfb51731e00e1f2cfb497a5ce9 (diff)
downloadopenssl-b65f851318ae22739928457037d20d89d131d38e.tar.gz
Make -passin -passout etc work again.
Fix leak in ca.c when using -passin.
Diffstat (limited to 'apps/ca.c')
-rw-r--r--apps/ca.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/ca.c b/apps/ca.c
index 1e34e50232..d41a9d5fc6 100644
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -264,6 +264,7 @@ int MAIN(int argc, char **argv)
{
ENGINE *e = NULL;
char *key=NULL,*passargin=NULL;
+ int free_key = 0;
int total=0;
int total_done=0;
int badops=0;
@@ -677,10 +678,14 @@ bad:
lookup_fail(section,ENV_PRIVATE_KEY);
goto err;
}
- if (!key && !app_passwd(bio_err, passargin, NULL, &key, NULL))
+ if (!key)
{
- BIO_printf(bio_err,"Error getting password\n");
- goto err;
+ free_key = 1;
+ if (!app_passwd(bio_err, passargin, NULL, &key, NULL))
+ {
+ BIO_printf(bio_err,"Error getting password\n");
+ goto err;
+ }
}
pkey = load_key(bio_err, keyfile, keyform, key, e,
"CA private key");
@@ -1577,6 +1582,8 @@ err:
if (ret) ERR_print_errors(bio_err);
app_RAND_write_file(randfile, bio_err);
+ if (free_key)
+ OPENSSL_free(key);
BN_free(serial);
TXT_DB_free(db);
EVP_PKEY_free(pkey);