summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2014-05-18 11:36:24 +0000
committerjsing <>2014-05-18 11:36:24 +0000
commitf1e8706ced8f59e8cca67cb75b29c503731e2555 (patch)
tree10eb763234a2d64874fa25d433f93e466943b13f
parentde4eef43c08fef5fd844116a63ef0e4e61d63f34 (diff)
downloadopenbsd-f1e8706ced8f59e8cca67cb75b29c503731e2555.tar.gz
openbsd-f1e8706ced8f59e8cca67cb75b29c503731e2555.tar.bz2
openbsd-f1e8706ced8f59e8cca67cb75b29c503731e2555.zip
bio_err is initialised in main, hence there is no need to initialise it
in each application (since there is no longer a non-monolithic mode). In typical OpenSSL fashion, the code is inconsistent and there are multiple ways that bio_err was initialised - none of them actually checked to see if the initialisation actually succeeded. Additionally, it is worth noting that in at least two cases bio_err was also being used before it would have been initialised. ok miod@
-rw-r--r--src/lib/libssl/src/apps/asn1pars.c4
-rw-r--r--src/lib/libssl/src/apps/ca.c3
-rw-r--r--src/lib/libssl/src/apps/ciphers.c2
-rw-r--r--src/lib/libssl/src/apps/cms.c4
-rw-r--r--src/lib/libssl/src/apps/crl.c4
-rw-r--r--src/lib/libssl/src/apps/crl2p7.c4
-rw-r--r--src/lib/libssl/src/apps/dgst.c3
-rw-r--r--src/lib/libssl/src/apps/dh.c4
-rw-r--r--src/lib/libssl/src/apps/dhparam.c4
-rw-r--r--src/lib/libssl/src/apps/dsa.c4
-rw-r--r--src/lib/libssl/src/apps/dsaparam.c4
-rw-r--r--src/lib/libssl/src/apps/ec.c4
-rw-r--r--src/lib/libssl/src/apps/ecparam.c4
-rw-r--r--src/lib/libssl/src/apps/enc.c4
-rw-r--r--src/lib/libssl/src/apps/engine.c4
-rw-r--r--src/lib/libssl/src/apps/errstr.c4
-rw-r--r--src/lib/libssl/src/apps/gendh.c3
-rw-r--r--src/lib/libssl/src/apps/gendsa.c4
-rw-r--r--src/lib/libssl/src/apps/genpkey.c3
-rw-r--r--src/lib/libssl/src/apps/genrsa.c5
-rw-r--r--src/lib/libssl/src/apps/nseq.c4
-rw-r--r--src/lib/libssl/src/apps/ocsp.c6
-rw-r--r--src/lib/libssl/src/apps/openssl.c5
-rw-r--r--src/lib/libssl/src/apps/passwd.c5
-rw-r--r--src/lib/libssl/src/apps/pkcs12.c3
-rw-r--r--src/lib/libssl/src/apps/pkcs7.c4
-rw-r--r--src/lib/libssl/src/apps/pkcs8.c3
-rw-r--r--src/lib/libssl/src/apps/pkey.c3
-rw-r--r--src/lib/libssl/src/apps/pkeyparam.c3
-rw-r--r--src/lib/libssl/src/apps/pkeyutl.c4
-rw-r--r--src/lib/libssl/src/apps/prime.c4
-rw-r--r--src/lib/libssl/src/apps/rand.c4
-rw-r--r--src/lib/libssl/src/apps/req.c4
-rw-r--r--src/lib/libssl/src/apps/rsa.c4
-rw-r--r--src/lib/libssl/src/apps/rsautl.c4
-rw-r--r--src/lib/libssl/src/apps/s_client.c3
-rw-r--r--src/lib/libssl/src/apps/s_server.c3
-rw-r--r--src/lib/libssl/src/apps/s_time.c3
-rw-r--r--src/lib/libssl/src/apps/sess_id.c4
-rw-r--r--src/lib/libssl/src/apps/smime.c4
-rw-r--r--src/lib/libssl/src/apps/speed.c5
-rw-r--r--src/lib/libssl/src/apps/spkac.c3
-rw-r--r--src/lib/libssl/src/apps/ts.c12
-rw-r--r--src/lib/libssl/src/apps/verify.c4
-rw-r--r--src/lib/libssl/src/apps/version.c4
-rw-r--r--src/lib/libssl/src/apps/x509.c4
46 files changed, 16 insertions, 168 deletions
diff --git a/src/lib/libssl/src/apps/asn1pars.c b/src/lib/libssl/src/apps/asn1pars.c
index 1459a5ac38..a8af0aa4e9 100644
--- a/src/lib/libssl/src/apps/asn1pars.c
+++ b/src/lib/libssl/src/apps/asn1pars.c
@@ -102,10 +102,6 @@ asn1parse_main(int argc, char **argv)
102 102
103 signal(SIGPIPE, SIG_IGN); 103 signal(SIGPIPE, SIG_IGN);
104 104
105 if (bio_err == NULL)
106 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
107 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
108
109 if (!load_config(bio_err, NULL)) 105 if (!load_config(bio_err, NULL))
110 goto end; 106 goto end;
111 107
diff --git a/src/lib/libssl/src/apps/ca.c b/src/lib/libssl/src/apps/ca.c
index a66a580ded..c771598802 100644
--- a/src/lib/libssl/src/apps/ca.c
+++ b/src/lib/libssl/src/apps/ca.c
@@ -329,9 +329,6 @@ ca_main(int argc, char **argv)
329 329
330 preserve = 0; 330 preserve = 0;
331 msie_hack = 0; 331 msie_hack = 0;
332 if (bio_err == NULL)
333 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
334 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
335 332
336 argc--; 333 argc--;
337 argv++; 334 argv++;
diff --git a/src/lib/libssl/src/apps/ciphers.c b/src/lib/libssl/src/apps/ciphers.c
index 3e2fb4c446..70d9a89409 100644
--- a/src/lib/libssl/src/apps/ciphers.c
+++ b/src/lib/libssl/src/apps/ciphers.c
@@ -95,8 +95,6 @@ ciphers_main(int argc, char **argv)
95 95
96 signal(SIGPIPE, SIG_IGN); 96 signal(SIGPIPE, SIG_IGN);
97 97
98 if (bio_err == NULL)
99 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
100 STDout = BIO_new_fp(stdout, BIO_NOCLOSE); 98 STDout = BIO_new_fp(stdout, BIO_NOCLOSE);
101 if (!load_config(bio_err, NULL)) 99 if (!load_config(bio_err, NULL))
102 goto end; 100 goto end;
diff --git a/src/lib/libssl/src/apps/cms.c b/src/lib/libssl/src/apps/cms.c
index 03459c64a2..fa1bd9a3a2 100644
--- a/src/lib/libssl/src/apps/cms.c
+++ b/src/lib/libssl/src/apps/cms.c
@@ -146,10 +146,6 @@ cms_main(int argc, char **argv)
146 146
147 signal(SIGPIPE, SIG_IGN); 147 signal(SIGPIPE, SIG_IGN);
148 148
149 if (bio_err == NULL) {
150 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
151 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
152 }
153 if (!load_config(bio_err, NULL)) 149 if (!load_config(bio_err, NULL))
154 goto end; 150 goto end;
155 151
diff --git a/src/lib/libssl/src/apps/crl.c b/src/lib/libssl/src/apps/crl.c
index fb963274ff..50ac0e118d 100644
--- a/src/lib/libssl/src/apps/crl.c
+++ b/src/lib/libssl/src/apps/crl.c
@@ -125,10 +125,6 @@ crl_main(int argc, char **argv)
125 125
126 signal(SIGPIPE, SIG_IGN); 126 signal(SIGPIPE, SIG_IGN);
127 127
128 if (bio_err == NULL)
129 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
130 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
131
132 if (!load_config(bio_err, NULL)) 128 if (!load_config(bio_err, NULL))
133 goto end; 129 goto end;
134 130
diff --git a/src/lib/libssl/src/apps/crl2p7.c b/src/lib/libssl/src/apps/crl2p7.c
index 4d3ff4d459..f972a394d6 100644
--- a/src/lib/libssl/src/apps/crl2p7.c
+++ b/src/lib/libssl/src/apps/crl2p7.c
@@ -98,10 +98,6 @@ crl2pkcs7_main(int argc, char **argv)
98 98
99 signal(SIGPIPE, SIG_IGN); 99 signal(SIGPIPE, SIG_IGN);
100 100
101 if (bio_err == NULL)
102 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
103 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
104
105 infile = NULL; 101 infile = NULL;
106 outfile = NULL; 102 outfile = NULL;
107 informat = FORMAT_PEM; 103 informat = FORMAT_PEM;
diff --git a/src/lib/libssl/src/apps/dgst.c b/src/lib/libssl/src/apps/dgst.c
index 523f5ccc6b..f2c228cc3d 100644
--- a/src/lib/libssl/src/apps/dgst.c
+++ b/src/lib/libssl/src/apps/dgst.c
@@ -135,9 +135,6 @@ dgst_main(int argc, char **argv)
135 BIO_printf(bio_err, "out of memory\n"); 135 BIO_printf(bio_err, "out of memory\n");
136 goto end; 136 goto end;
137 } 137 }
138 if (bio_err == NULL)
139 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
140 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
141 138
142 if (!load_config(bio_err, NULL)) 139 if (!load_config(bio_err, NULL))
143 goto end; 140 goto end;
diff --git a/src/lib/libssl/src/apps/dh.c b/src/lib/libssl/src/apps/dh.c
index a02bae93c5..7e5e142760 100644
--- a/src/lib/libssl/src/apps/dh.c
+++ b/src/lib/libssl/src/apps/dh.c
@@ -98,10 +98,6 @@ dh_main(int argc, char **argv)
98 98
99 signal(SIGPIPE, SIG_IGN); 99 signal(SIGPIPE, SIG_IGN);
100 100
101 if (bio_err == NULL)
102 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
103 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
104
105 if (!load_config(bio_err, NULL)) 101 if (!load_config(bio_err, NULL))
106 goto end; 102 goto end;
107 103
diff --git a/src/lib/libssl/src/apps/dhparam.c b/src/lib/libssl/src/apps/dhparam.c
index b09f6418e3..0cb99c5340 100644
--- a/src/lib/libssl/src/apps/dhparam.c
+++ b/src/lib/libssl/src/apps/dhparam.c
@@ -164,10 +164,6 @@ dhparam_main(int argc, char **argv)
164 164
165 signal(SIGPIPE, SIG_IGN); 165 signal(SIGPIPE, SIG_IGN);
166 166
167 if (bio_err == NULL)
168 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
169 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
170
171 if (!load_config(bio_err, NULL)) 167 if (!load_config(bio_err, NULL))
172 goto end; 168 goto end;
173 169
diff --git a/src/lib/libssl/src/apps/dsa.c b/src/lib/libssl/src/apps/dsa.c
index f9be2392d8..81040193c7 100644
--- a/src/lib/libssl/src/apps/dsa.c
+++ b/src/lib/libssl/src/apps/dsa.c
@@ -115,10 +115,6 @@ dsa_main(int argc, char **argv)
115 115
116 signal(SIGPIPE, SIG_IGN); 116 signal(SIGPIPE, SIG_IGN);
117 117
118 if (bio_err == NULL)
119 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
120 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
121
122 if (!load_config(bio_err, NULL)) 118 if (!load_config(bio_err, NULL))
123 goto end; 119 goto end;
124 120
diff --git a/src/lib/libssl/src/apps/dsaparam.c b/src/lib/libssl/src/apps/dsaparam.c
index 0db04ed6f4..6488c4b69d 100644
--- a/src/lib/libssl/src/apps/dsaparam.c
+++ b/src/lib/libssl/src/apps/dsaparam.c
@@ -126,10 +126,6 @@ dsaparam_main(int argc, char **argv)
126 126
127 signal(SIGPIPE, SIG_IGN); 127 signal(SIGPIPE, SIG_IGN);
128 128
129 if (bio_err == NULL)
130 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
131 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
132
133 if (!load_config(bio_err, NULL)) 129 if (!load_config(bio_err, NULL))
134 goto end; 130 goto end;
135 131
diff --git a/src/lib/libssl/src/apps/ec.c b/src/lib/libssl/src/apps/ec.c
index 0fcf81a79e..3f4a1d0045 100644
--- a/src/lib/libssl/src/apps/ec.c
+++ b/src/lib/libssl/src/apps/ec.c
@@ -102,10 +102,6 @@ ec_main(int argc, char **argv)
102 102
103 signal(SIGPIPE, SIG_IGN); 103 signal(SIGPIPE, SIG_IGN);
104 104
105 if (bio_err == NULL)
106 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
107 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
108
109 if (!load_config(bio_err, NULL)) 105 if (!load_config(bio_err, NULL))
110 goto end; 106 goto end;
111 107
diff --git a/src/lib/libssl/src/apps/ecparam.c b/src/lib/libssl/src/apps/ecparam.c
index 49aeab8355..84ecba72f5 100644
--- a/src/lib/libssl/src/apps/ecparam.c
+++ b/src/lib/libssl/src/apps/ecparam.c
@@ -136,10 +136,6 @@ ecparam_main(int argc, char **argv)
136 136
137 signal(SIGPIPE, SIG_IGN); 137 signal(SIGPIPE, SIG_IGN);
138 138
139 if (bio_err == NULL)
140 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
141 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
142
143 if (!load_config(bio_err, NULL)) 139 if (!load_config(bio_err, NULL))
144 goto end; 140 goto end;
145 141
diff --git a/src/lib/libssl/src/apps/enc.c b/src/lib/libssl/src/apps/enc.c
index cda196a782..0ac6a43f6a 100644
--- a/src/lib/libssl/src/apps/enc.c
+++ b/src/lib/libssl/src/apps/enc.c
@@ -131,10 +131,6 @@ enc_main(int argc, char **argv)
131 131
132 signal(SIGPIPE, SIG_IGN); 132 signal(SIGPIPE, SIG_IGN);
133 133
134 if (bio_err == NULL)
135 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
136 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
137
138 if (!load_config(bio_err, NULL)) 134 if (!load_config(bio_err, NULL))
139 goto end; 135 goto end;
140 136
diff --git a/src/lib/libssl/src/apps/engine.c b/src/lib/libssl/src/apps/engine.c
index 6134de94cb..7b11ea57d9 100644
--- a/src/lib/libssl/src/apps/engine.c
+++ b/src/lib/libssl/src/apps/engine.c
@@ -339,11 +339,9 @@ engine_main(int argc, char **argv)
339 signal(SIGPIPE, SIG_IGN); 339 signal(SIGPIPE, SIG_IGN);
340 SSL_load_error_strings(); 340 SSL_load_error_strings();
341 341
342 if (bio_err == NULL)
343 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
344
345 if (!load_config(bio_err, NULL)) 342 if (!load_config(bio_err, NULL))
346 goto end; 343 goto end;
344
347 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); 345 bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
348 346
349 argc--; 347 argc--;
diff --git a/src/lib/libssl/src/apps/errstr.c b/src/lib/libssl/src/apps/errstr.c
index 9766a54b08..4605f098ab 100644
--- a/src/lib/libssl/src/apps/errstr.c
+++ b/src/lib/libssl/src/apps/errstr.c
@@ -77,10 +77,6 @@ errstr_main(int argc, char **argv)
77 77
78 signal(SIGPIPE, SIG_IGN); 78 signal(SIGPIPE, SIG_IGN);
79 79
80 if (bio_err == NULL)
81 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
82 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
83
84 SSL_load_error_strings(); 80 SSL_load_error_strings();
85 81
86 if ((argc > 1) && (strcmp(argv[1], "-stats") == 0)) { 82 if ((argc > 1) && (strcmp(argv[1], "-stats") == 0)) {
diff --git a/src/lib/libssl/src/apps/gendh.c b/src/lib/libssl/src/apps/gendh.c
index 07e8b33390..4dd5c02a9e 100644
--- a/src/lib/libssl/src/apps/gendh.c
+++ b/src/lib/libssl/src/apps/gendh.c
@@ -101,9 +101,6 @@ gendh_main(int argc, char **argv)
101 signal(SIGPIPE, SIG_IGN); 101 signal(SIGPIPE, SIG_IGN);
102 102
103 BN_GENCB_set(&cb, dh_cb, bio_err); 103 BN_GENCB_set(&cb, dh_cb, bio_err);
104 if (bio_err == NULL)
105 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
106 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
107 104
108 if (!load_config(bio_err, NULL)) 105 if (!load_config(bio_err, NULL))
109 goto end; 106 goto end;
diff --git a/src/lib/libssl/src/apps/gendsa.c b/src/lib/libssl/src/apps/gendsa.c
index 07eb756372..df0993edb4 100644
--- a/src/lib/libssl/src/apps/gendsa.c
+++ b/src/lib/libssl/src/apps/gendsa.c
@@ -90,10 +90,6 @@ gendsa_main(int argc, char **argv)
90 90
91 signal(SIGPIPE, SIG_IGN); 91 signal(SIGPIPE, SIG_IGN);
92 92
93 if (bio_err == NULL)
94 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
95 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
96
97 if (!load_config(bio_err, NULL)) 93 if (!load_config(bio_err, NULL))
98 goto end; 94 goto end;
99 95
diff --git a/src/lib/libssl/src/apps/genpkey.c b/src/lib/libssl/src/apps/genpkey.c
index 8d2f6d6ae8..1b3bc57e7d 100644
--- a/src/lib/libssl/src/apps/genpkey.c
+++ b/src/lib/libssl/src/apps/genpkey.c
@@ -91,9 +91,6 @@ genpkey_main(int argc, char **argv)
91 91
92 int do_param = 0; 92 int do_param = 0;
93 93
94 if (bio_err == NULL)
95 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
96
97 if (!load_config(bio_err, NULL)) 94 if (!load_config(bio_err, NULL))
98 goto end; 95 goto end;
99 96
diff --git a/src/lib/libssl/src/apps/genrsa.c b/src/lib/libssl/src/apps/genrsa.c
index 643e20da2f..7e5dd2b239 100644
--- a/src/lib/libssl/src/apps/genrsa.c
+++ b/src/lib/libssl/src/apps/genrsa.c
@@ -112,12 +112,9 @@ genrsa_main(int argc, char **argv)
112 signal(SIGPIPE, SIG_IGN); 112 signal(SIGPIPE, SIG_IGN);
113 BN_GENCB_set(&cb, genrsa_cb, bio_err); 113 BN_GENCB_set(&cb, genrsa_cb, bio_err);
114 114
115 if (bio_err == NULL)
116 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
117 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
118
119 if (!load_config(bio_err, NULL)) 115 if (!load_config(bio_err, NULL))
120 goto err; 116 goto err;
117
121 if ((out = BIO_new(BIO_s_file())) == NULL) { 118 if ((out = BIO_new(BIO_s_file())) == NULL) {
122 BIO_printf(bio_err, "unable to create BIO for output\n"); 119 BIO_printf(bio_err, "unable to create BIO for output\n");
123 goto err; 120 goto err;
diff --git a/src/lib/libssl/src/apps/nseq.c b/src/lib/libssl/src/apps/nseq.c
index 120792edbc..0a1512afcf 100644
--- a/src/lib/libssl/src/apps/nseq.c
+++ b/src/lib/libssl/src/apps/nseq.c
@@ -75,9 +75,9 @@ nseq_main(int argc, char **argv)
75 NETSCAPE_CERT_SEQUENCE *seq = NULL; 75 NETSCAPE_CERT_SEQUENCE *seq = NULL;
76 int i, ret = 1; 76 int i, ret = 1;
77 int badarg = 0; 77 int badarg = 0;
78 if (bio_err == NULL) 78
79 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
80 ERR_load_crypto_strings(); 79 ERR_load_crypto_strings();
80
81 args = argv + 1; 81 args = argv + 1;
82 while (!badarg && *args && *args[0] == '-') { 82 while (!badarg && *args && *args[0] == '-') {
83 if (!strcmp(*args, "-toseq")) 83 if (!strcmp(*args, "-toseq"))
diff --git a/src/lib/libssl/src/apps/ocsp.c b/src/lib/libssl/src/apps/ocsp.c
index 461f21d6eb..95778210db 100644
--- a/src/lib/libssl/src/apps/ocsp.c
+++ b/src/lib/libssl/src/apps/ocsp.c
@@ -137,7 +137,6 @@ ocsp_main(int argc, char **argv)
137 int ignore_err = 0; 137 int ignore_err = 0;
138 STACK_OF(OPENSSL_STRING) * reqnames = NULL; 138 STACK_OF(OPENSSL_STRING) * reqnames = NULL;
139 STACK_OF(OCSP_CERTID) * ids = NULL; 139 STACK_OF(OCSP_CERTID) * ids = NULL;
140
141 X509 *rca_cert = NULL; 140 X509 *rca_cert = NULL;
142 char *ridx_filename = NULL; 141 char *ridx_filename = NULL;
143 char *rca_filename = NULL; 142 char *rca_filename = NULL;
@@ -145,13 +144,12 @@ ocsp_main(int argc, char **argv)
145 int nmin = 0, ndays = -1; 144 int nmin = 0, ndays = -1;
146 const EVP_MD *cert_id_md = NULL; 145 const EVP_MD *cert_id_md = NULL;
147 146
148 if (bio_err == NULL)
149 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
150
151 if (!load_config(bio_err, NULL)) 147 if (!load_config(bio_err, NULL))
152 goto end; 148 goto end;
149
153 SSL_load_error_strings(); 150 SSL_load_error_strings();
154 OpenSSL_add_ssl_algorithms(); 151 OpenSSL_add_ssl_algorithms();
152
155 args = argv + 1; 153 args = argv + 1;
156 reqnames = sk_OPENSSL_STRING_new_null(); 154 reqnames = sk_OPENSSL_STRING_new_null();
157 ids = sk_OCSP_CERTID_new_null(); 155 ids = sk_OCSP_CERTID_new_null();
diff --git a/src/lib/libssl/src/apps/openssl.c b/src/lib/libssl/src/apps/openssl.c
index 1dbc7f464f..2250701f68 100644
--- a/src/lib/libssl/src/apps/openssl.c
+++ b/src/lib/libssl/src/apps/openssl.c
@@ -109,6 +109,7 @@
109 * 109 *
110 */ 110 */
111 111
112#include <err.h>
112#include <stdio.h> 113#include <stdio.h>
113#include <string.h> 114#include <string.h>
114#include <stdlib.h> 115#include <stdlib.h>
@@ -252,9 +253,9 @@ main(int argc, char **argv)
252 arg.data = NULL; 253 arg.data = NULL;
253 arg.count = 0; 254 arg.count = 0;
254 255
256 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
255 if (bio_err == NULL) 257 if (bio_err == NULL)
256 if ((bio_err = BIO_new(BIO_s_file())) != NULL) 258 errx(1, "failed to initialise bio_err");
257 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
258 259
259 CRYPTO_set_locking_callback(lock_dbg_cb); 260 CRYPTO_set_locking_callback(lock_dbg_cb);
260 261
diff --git a/src/lib/libssl/src/apps/passwd.c b/src/lib/libssl/src/apps/passwd.c
index 105625b4ed..30a38aafb8 100644
--- a/src/lib/libssl/src/apps/passwd.c
+++ b/src/lib/libssl/src/apps/passwd.c
@@ -75,12 +75,9 @@ passwd_main(int argc, char **argv)
75 75
76 signal(SIGPIPE, SIG_IGN); 76 signal(SIGPIPE, SIG_IGN);
77 77
78 if (bio_err == NULL)
79 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
80 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
81
82 if (!load_config(bio_err, NULL)) 78 if (!load_config(bio_err, NULL))
83 goto err; 79 goto err;
80
84 out = BIO_new(BIO_s_file()); 81 out = BIO_new(BIO_s_file());
85 if (out == NULL) 82 if (out == NULL)
86 goto err; 83 goto err;
diff --git a/src/lib/libssl/src/apps/pkcs12.c b/src/lib/libssl/src/apps/pkcs12.c
index 8ea749616d..f23d902eb3 100644
--- a/src/lib/libssl/src/apps/pkcs12.c
+++ b/src/lib/libssl/src/apps/pkcs12.c
@@ -135,15 +135,12 @@ pkcs12_main(int argc, char **argv)
135 cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC; 135 cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
136 136
137 enc = EVP_des_ede3_cbc(); 137 enc = EVP_des_ede3_cbc();
138 if (bio_err == NULL)
139 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
140 138
141 if (!load_config(bio_err, NULL)) 139 if (!load_config(bio_err, NULL))
142 goto end; 140 goto end;
143 141
144 args = argv + 1; 142 args = argv + 1;
145 143
146
147 while (*args) { 144 while (*args) {
148 if (*args[0] == '-') { 145 if (*args[0] == '-') {
149 if (!strcmp(*args, "-nokeys")) 146 if (!strcmp(*args, "-nokeys"))
diff --git a/src/lib/libssl/src/apps/pkcs7.c b/src/lib/libssl/src/apps/pkcs7.c
index c2093ddd12..8540a3f6c2 100644
--- a/src/lib/libssl/src/apps/pkcs7.c
+++ b/src/lib/libssl/src/apps/pkcs7.c
@@ -94,10 +94,6 @@ pkcs7_main(int argc, char **argv)
94 94
95 signal(SIGPIPE, SIG_IGN); 95 signal(SIGPIPE, SIG_IGN);
96 96
97 if (bio_err == NULL)
98 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
99 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
100
101 if (!load_config(bio_err, NULL)) 97 if (!load_config(bio_err, NULL))
102 goto end; 98 goto end;
103 99
diff --git a/src/lib/libssl/src/apps/pkcs8.c b/src/lib/libssl/src/apps/pkcs8.c
index eb36946d48..ee6a48fc14 100644
--- a/src/lib/libssl/src/apps/pkcs8.c
+++ b/src/lib/libssl/src/apps/pkcs8.c
@@ -90,9 +90,6 @@ pkcs8_main(int argc, char **argv)
90 char *engine = NULL; 90 char *engine = NULL;
91#endif 91#endif
92 92
93 if (bio_err == NULL)
94 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
95
96 if (!load_config(bio_err, NULL)) 93 if (!load_config(bio_err, NULL))
97 goto end; 94 goto end;
98 95
diff --git a/src/lib/libssl/src/apps/pkey.c b/src/lib/libssl/src/apps/pkey.c
index bd439cbf79..627278fabc 100644
--- a/src/lib/libssl/src/apps/pkey.c
+++ b/src/lib/libssl/src/apps/pkey.c
@@ -83,9 +83,6 @@ pkey_main(int argc, char **argv)
83#endif 83#endif
84 int ret = 1; 84 int ret = 1;
85 85
86 if (bio_err == NULL)
87 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
88
89 if (!load_config(bio_err, NULL)) 86 if (!load_config(bio_err, NULL))
90 goto end; 87 goto end;
91 88
diff --git a/src/lib/libssl/src/apps/pkeyparam.c b/src/lib/libssl/src/apps/pkeyparam.c
index b653dee794..caeaf193df 100644
--- a/src/lib/libssl/src/apps/pkeyparam.c
+++ b/src/lib/libssl/src/apps/pkeyparam.c
@@ -78,9 +78,6 @@ pkeyparam_main(int argc, char **argv)
78#endif 78#endif
79 int ret = 1; 79 int ret = 1;
80 80
81 if (bio_err == NULL)
82 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
83
84 if (!load_config(bio_err, NULL)) 81 if (!load_config(bio_err, NULL))
85 goto end; 82 goto end;
86 83
diff --git a/src/lib/libssl/src/apps/pkeyutl.c b/src/lib/libssl/src/apps/pkeyutl.c
index 64ccd142ce..c112c773b9 100644
--- a/src/lib/libssl/src/apps/pkeyutl.c
+++ b/src/lib/libssl/src/apps/pkeyutl.c
@@ -106,11 +106,9 @@ pkeyutl_main(int argc, char **argv)
106 argc--; 106 argc--;
107 argv++; 107 argv++;
108 108
109 if (!bio_err)
110 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
111
112 if (!load_config(bio_err, NULL)) 109 if (!load_config(bio_err, NULL))
113 goto end; 110 goto end;
111
114 ERR_load_crypto_strings(); 112 ERR_load_crypto_strings();
115 OpenSSL_add_all_algorithms(); 113 OpenSSL_add_all_algorithms();
116 114
diff --git a/src/lib/libssl/src/apps/prime.c b/src/lib/libssl/src/apps/prime.c
index 5d15f5fbd7..c6f562a7e3 100644
--- a/src/lib/libssl/src/apps/prime.c
+++ b/src/lib/libssl/src/apps/prime.c
@@ -69,10 +69,6 @@ prime_main(int argc, char **argv)
69 69
70 signal(SIGPIPE, SIG_IGN); 70 signal(SIGPIPE, SIG_IGN);
71 71
72 if (bio_err == NULL)
73 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
74 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
75
76 --argc; 72 --argc;
77 ++argv; 73 ++argv;
78 while (argc >= 1 && **argv == '-') { 74 while (argc >= 1 && **argv == '-') {
diff --git a/src/lib/libssl/src/apps/rand.c b/src/lib/libssl/src/apps/rand.c
index 458d5ac7b8..355a42e184 100644
--- a/src/lib/libssl/src/apps/rand.c
+++ b/src/lib/libssl/src/apps/rand.c
@@ -90,10 +90,6 @@ rand_main(int argc, char **argv)
90 90
91 signal(SIGPIPE, SIG_IGN); 91 signal(SIGPIPE, SIG_IGN);
92 92
93 if (bio_err == NULL)
94 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
95 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
96
97 if (!load_config(bio_err, NULL)) 93 if (!load_config(bio_err, NULL))
98 goto err; 94 goto err;
99 95
diff --git a/src/lib/libssl/src/apps/req.c b/src/lib/libssl/src/apps/req.c
index 5cfbc442ea..26a3e1196c 100644
--- a/src/lib/libssl/src/apps/req.c
+++ b/src/lib/libssl/src/apps/req.c
@@ -190,10 +190,6 @@ req_main(int argc, char **argv)
190#endif 190#endif
191 signal(SIGPIPE, SIG_IGN); 191 signal(SIGPIPE, SIG_IGN);
192 192
193 if (bio_err == NULL)
194 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
195 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
196
197 infile = NULL; 193 infile = NULL;
198 outfile = NULL; 194 outfile = NULL;
199 informat = FORMAT_PEM; 195 informat = FORMAT_PEM;
diff --git a/src/lib/libssl/src/apps/rsa.c b/src/lib/libssl/src/apps/rsa.c
index 286183582a..3e0b2ebfac 100644
--- a/src/lib/libssl/src/apps/rsa.c
+++ b/src/lib/libssl/src/apps/rsa.c
@@ -118,10 +118,6 @@ rsa_main(int argc, char **argv)
118 118
119 signal(SIGPIPE, SIG_IGN); 119 signal(SIGPIPE, SIG_IGN);
120 120
121 if (bio_err == NULL)
122 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
123 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
124
125 if (!load_config(bio_err, NULL)) 121 if (!load_config(bio_err, NULL))
126 goto end; 122 goto end;
127 123
diff --git a/src/lib/libssl/src/apps/rsautl.c b/src/lib/libssl/src/apps/rsautl.c
index 9c5b96fa2a..04992ae609 100644
--- a/src/lib/libssl/src/apps/rsautl.c
+++ b/src/lib/libssl/src/apps/rsautl.c
@@ -107,11 +107,9 @@ rsautl_main(int argc, char **argv)
107 argc--; 107 argc--;
108 argv++; 108 argv++;
109 109
110 if (!bio_err)
111 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
112
113 if (!load_config(bio_err, NULL)) 110 if (!load_config(bio_err, NULL))
114 goto end; 111 goto end;
112
115 ERR_load_crypto_strings(); 113 ERR_load_crypto_strings();
116 OpenSSL_add_all_algorithms(); 114 OpenSSL_add_all_algorithms();
117 pad = RSA_PKCS1_PADDING; 115 pad = RSA_PKCS1_PADDING;
diff --git a/src/lib/libssl/src/apps/s_client.c b/src/lib/libssl/src/apps/s_client.c
index b90a096b40..7549c980e0 100644
--- a/src/lib/libssl/src/apps/s_client.c
+++ b/src/lib/libssl/src/apps/s_client.c
@@ -475,9 +475,6 @@ s_client_main(int argc, char **argv)
475 c_msg = 0; 475 c_msg = 0;
476 c_showcerts = 0; 476 c_showcerts = 0;
477 477
478 if (bio_err == NULL)
479 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
480
481 if (!load_config(bio_err, NULL)) 478 if (!load_config(bio_err, NULL))
482 goto end; 479 goto end;
483 480
diff --git a/src/lib/libssl/src/apps/s_server.c b/src/lib/libssl/src/apps/s_server.c
index 6cb43ed45d..67886bbb58 100644
--- a/src/lib/libssl/src/apps/s_server.c
+++ b/src/lib/libssl/src/apps/s_server.c
@@ -725,9 +725,6 @@ s_server_main(int argc, char *argv[])
725 signal(SIGPIPE, SIG_IGN); 725 signal(SIGPIPE, SIG_IGN);
726 s_server_init(); 726 s_server_init();
727 727
728 if (bio_err == NULL)
729 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
730
731 if (!load_config(bio_err, NULL)) 728 if (!load_config(bio_err, NULL))
732 goto end; 729 goto end;
733 730
diff --git a/src/lib/libssl/src/apps/s_time.c b/src/lib/libssl/src/apps/s_time.c
index 8ce2c671a2..4cf62ffea6 100644
--- a/src/lib/libssl/src/apps/s_time.c
+++ b/src/lib/libssl/src/apps/s_time.c
@@ -318,9 +318,6 @@ s_time_main(int argc, char **argv)
318 signal(SIGPIPE, SIG_IGN); 318 signal(SIGPIPE, SIG_IGN);
319 s_time_init(); 319 s_time_init();
320 320
321 if (bio_err == NULL)
322 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
323
324 s_time_meth = SSLv23_client_method(); 321 s_time_meth = SSLv23_client_method();
325 322
326 /* parse the command line arguments */ 323 /* parse the command line arguments */
diff --git a/src/lib/libssl/src/apps/sess_id.c b/src/lib/libssl/src/apps/sess_id.c
index 95bc71fe70..49766fdb65 100644
--- a/src/lib/libssl/src/apps/sess_id.c
+++ b/src/lib/libssl/src/apps/sess_id.c
@@ -99,10 +99,6 @@ sess_id_main(int argc, char **argv)
99 99
100 signal(SIGPIPE, SIG_IGN); 100 signal(SIGPIPE, SIG_IGN);
101 101
102 if (bio_err == NULL)
103 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
104 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
105
106 informat = FORMAT_PEM; 102 informat = FORMAT_PEM;
107 outformat = FORMAT_PEM; 103 outformat = FORMAT_PEM;
108 104
diff --git a/src/lib/libssl/src/apps/smime.c b/src/lib/libssl/src/apps/smime.c
index 4fdf170df7..f7d56b3005 100644
--- a/src/lib/libssl/src/apps/smime.c
+++ b/src/lib/libssl/src/apps/smime.c
@@ -122,10 +122,6 @@ smime_main(int argc, char **argv)
122 122
123 signal(SIGPIPE, SIG_IGN); 123 signal(SIGPIPE, SIG_IGN);
124 124
125 if (bio_err == NULL) {
126 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
127 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
128 }
129 if (!load_config(bio_err, NULL)) 125 if (!load_config(bio_err, NULL))
130 goto end; 126 goto end;
131 127
diff --git a/src/lib/libssl/src/apps/speed.c b/src/lib/libssl/src/apps/speed.c
index 76ab66c547..f96e901917 100644
--- a/src/lib/libssl/src/apps/speed.c
+++ b/src/lib/libssl/src/apps/speed.c
@@ -537,11 +537,6 @@ speed_main(int argc, char **argv)
537 } 537 }
538#endif 538#endif
539 539
540
541 if (bio_err == NULL)
542 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
543 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
544
545 if (!load_config(bio_err, NULL)) 540 if (!load_config(bio_err, NULL))
546 goto end; 541 goto end;
547 542
diff --git a/src/lib/libssl/src/apps/spkac.c b/src/lib/libssl/src/apps/spkac.c
index 7de9450b87..8fa21d9826 100644
--- a/src/lib/libssl/src/apps/spkac.c
+++ b/src/lib/libssl/src/apps/spkac.c
@@ -98,9 +98,6 @@ spkac_main(int argc, char **argv)
98 98
99 signal(SIGPIPE, SIG_IGN); 99 signal(SIGPIPE, SIG_IGN);
100 100
101 if (!bio_err)
102 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
103
104 if (!load_config(bio_err, NULL)) 101 if (!load_config(bio_err, NULL))
105 goto end; 102 goto end;
106 103
diff --git a/src/lib/libssl/src/apps/ts.c b/src/lib/libssl/src/apps/ts.c
index d154616a85..c2d333cf7e 100644
--- a/src/lib/libssl/src/apps/ts.c
+++ b/src/lib/libssl/src/apps/ts.c
@@ -153,15 +153,11 @@ ts_main(int argc, char **argv)
153 int token_in = 0; 153 int token_in = 0;
154 /* Output is ContentInfo instead of TimeStampResp. */ 154 /* Output is ContentInfo instead of TimeStampResp. */
155 int token_out = 0; 155 int token_out = 0;
156 int free_bio_err = 0;
157 156
158 ERR_load_crypto_strings(); 157 ERR_load_crypto_strings();
158
159 signal(SIGPIPE, SIG_IGN); 159 signal(SIGPIPE, SIG_IGN);
160 160
161 if (bio_err == NULL && (bio_err = BIO_new(BIO_s_file())) != NULL) {
162 free_bio_err = 1;
163 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
164 }
165 if (!load_config(bio_err, NULL)) 161 if (!load_config(bio_err, NULL))
166 goto cleanup; 162 goto cleanup;
167 163
@@ -338,15 +334,13 @@ usage:
338 "-in response.tsr [-token_in] " 334 "-in response.tsr [-token_in] "
339 "-CApath ca_path -CAfile ca_file.pem " 335 "-CApath ca_path -CAfile ca_file.pem "
340 "-untrusted cert_file.pem\n"); 336 "-untrusted cert_file.pem\n");
337
341cleanup: 338cleanup:
342 /* Clean up. */ 339 /* Clean up. */
343 NCONF_free(conf); 340 NCONF_free(conf);
344 free(password); 341 free(password);
345 OBJ_cleanup(); 342 OBJ_cleanup();
346 if (free_bio_err) { 343
347 BIO_free_all(bio_err);
348 bio_err = NULL;
349 }
350 return (ret); 344 return (ret);
351} 345}
352 346
diff --git a/src/lib/libssl/src/apps/verify.c b/src/lib/libssl/src/apps/verify.c
index e2d34bccb3..b73956bc57 100644
--- a/src/lib/libssl/src/apps/verify.c
+++ b/src/lib/libssl/src/apps/verify.c
@@ -99,10 +99,6 @@ verify_main(int argc, char **argv)
99 99
100 signal(SIGPIPE, SIG_IGN); 100 signal(SIGPIPE, SIG_IGN);
101 101
102 if (bio_err == NULL)
103 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
104 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
105
106 if (!load_config(bio_err, NULL)) 102 if (!load_config(bio_err, NULL))
107 goto end; 103 goto end;
108 104
diff --git a/src/lib/libssl/src/apps/version.c b/src/lib/libssl/src/apps/version.c
index 927704b65e..e7c58b5ae0 100644
--- a/src/lib/libssl/src/apps/version.c
+++ b/src/lib/libssl/src/apps/version.c
@@ -141,10 +141,6 @@ version_main(int argc, char **argv)
141 141
142 signal(SIGPIPE, SIG_IGN); 142 signal(SIGPIPE, SIG_IGN);
143 143
144 if (bio_err == NULL)
145 if ((bio_err = BIO_new(BIO_s_file())) != NULL)
146 BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
147
148 if (argc == 1) 144 if (argc == 1)
149 version = 1; 145 version = 1;
150 for (i = 1; i < argc; i++) { 146 for (i = 1; i < argc; i++) {
diff --git a/src/lib/libssl/src/apps/x509.c b/src/lib/libssl/src/apps/x509.c
index a7c451948b..389b752151 100644
--- a/src/lib/libssl/src/apps/x509.c
+++ b/src/lib/libssl/src/apps/x509.c
@@ -210,11 +210,9 @@ x509_main(int argc, char **argv)
210 210
211 signal(SIGPIPE, SIG_IGN); 211 signal(SIGPIPE, SIG_IGN);
212 212
213 if (bio_err == NULL)
214 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
215
216 if (!load_config(bio_err, NULL)) 213 if (!load_config(bio_err, NULL))
217 goto end; 214 goto end;
215
218 STDout = BIO_new_fp(stdout, BIO_NOCLOSE); 216 STDout = BIO_new_fp(stdout, BIO_NOCLOSE);
219 217
220 informat = FORMAT_PEM; 218 informat = FORMAT_PEM;