summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2015-06-04 14:26:55 -0400
committerRich Salz <rsalz@openssl.org>2015-06-09 12:48:55 -0400
commit7768e116dc0f2ad7c8d2241b887fc6c66d03e3bb (patch)
treebb758dbc279a225068e96c01c9ceae36f3b26b61
parent51b04a6117510d8a771f619cb419985f4dec32bb (diff)
Use bio_err not stderr in apps.
Except for VMS startup code. Reviewed-by: Richard Levitte <levitte@openssl.org>
-rw-r--r--apps/openssl.c27
-rw-r--r--apps/passwd.c4
-rw-r--r--apps/s_cb.c5
-rw-r--r--apps/s_server.c8
-rw-r--r--apps/s_socket.c6
-rw-r--r--apps/s_time.c4
-rw-r--r--apps/speed.c12
7 files changed, 32 insertions, 34 deletions
diff --git a/apps/openssl.c b/apps/openssl.c
index 9a152f54e3..911772649a 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -264,10 +264,9 @@ static void lock_dbg_cb(int mode, int type, const char *file, int line)
err:
if (errstr) {
- /* we cannot use bio_err here */
- fprintf(stderr,
- "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n",
- errstr, mode, type, file, line);
+ BIO_printf(bio_err,
+ "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n",
+ errstr, mode, type, file, line);
}
}
@@ -348,6 +347,12 @@ int main(int argc, char *argv[])
arg.argv = NULL;
arg.size = 0;
+ /* Set up some of the environment. */
+ default_config_file = make_config_name();
+ bio_in = dup_bio_in();
+ bio_out = dup_bio_out();
+ bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
+
#if defined( OPENSSL_SYS_VMS)
copied_argv = argv = copy_argv(&argc, argv);
#endif
@@ -369,12 +374,12 @@ int main(int argc, char *argv[])
#ifdef OPENSSL_FIPS
if (!FIPS_mode_set(1)) {
ERR_load_crypto_strings();
- ERR_print_errors(BIO_new_fp(stderr, BIO_NOCLOSE));
- EXIT(1);
+ ERR_print_errors(bio_err);
+ return 1;
}
#else
- fprintf(stderr, "FIPS mode not supported.\n");
- EXIT(1);
+ BIO_printf(bio_err, "FIPS mode not supported.\n");
+ return 1;
#endif
}
@@ -393,12 +398,6 @@ int main(int argc, char *argv[])
prog = prog_init();
pname = opt_progname(argv[0]);
- /* Lets load up our environment a little */
- default_config_file = make_config_name();
- bio_in = dup_bio_in();
- bio_out = dup_bio_out();
- bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
-
/* first check the program name */
f.name = pname;
fp = lh_FUNCTION_retrieve(prog, &f);
diff --git a/apps/passwd.c b/apps/passwd.c
index 2e376290d0..0e168c4a86 100644
--- a/apps/passwd.c
+++ b/apps/passwd.c
@@ -496,7 +496,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
int passwd_main(int argc, char **argv)
{
- fputs("Program not available.\n", stderr)
- return (1);
+ BIO_printf(bio_err, "Program not available.\n");
+ return (1);
}
#endif
diff --git a/apps/s_cb.c b/apps/s_cb.c
index 35366c5675..44e70f2179 100644
--- a/apps/s_cb.c
+++ b/apps/s_cb.c
@@ -931,8 +931,9 @@ static int set_cert_cb(SSL *ssl, void *arg)
static int retry_cnt;
if (retry_cnt < 5) {
retry_cnt++;
- fprintf(stderr, "Certificate callback retry test: count %d\n",
- retry_cnt);
+ BIO_printf(bio_err,
+ "Certificate callback retry test: count %d\n",
+ retry_cnt);
return -1;
}
#endif
diff --git a/apps/s_server.c b/apps/s_server.c
index 6bd0257a7a..8354386ba4 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -2376,8 +2376,8 @@ static int init_ssl_connection(SSL *con)
{
while (i <= 0 && SSL_get_error(con, i) == SSL_ERROR_WANT_X509_LOOKUP
&& SSL_state(con) == SSL3_ST_SR_CLNT_HELLO_C) {
- fprintf(stderr,
- "LOOKUP from certificate callback during accept\n");
+ BIO_printf(bio_err,
+ "LOOKUP from certificate callback during accept\n");
i = SSL_accept(con);
}
}
@@ -2811,10 +2811,10 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
#ifdef RENEG
total_bytes += i;
- fprintf(stderr, "%d\n", i);
+ BIO_printf(bio_err, "%d\n", i);
if (total_bytes > 3 * 1024) {
total_bytes = 0;
- fprintf(stderr, "RENEGOTIATE\n");
+ BIO_printf(bio_err, "RENEGOTIATE\n");
SSL_renegotiate(con);
}
#endif
diff --git a/apps/s_socket.c b/apps/s_socket.c
index 1ca0d3a94a..c1faffc494 100644
--- a/apps/s_socket.c
+++ b/apps/s_socket.c
@@ -539,8 +539,7 @@ static int do_accept(int acc_sock, int *sock, char **host)
*/
goto redoit;
}
- fprintf(stderr, "errno=%d ", errno);
- perror("accept");
+ BIO_printf(bio_err, "accept errno=%d, %s\n", errno, strerror(errno));
# endif
return (0);
}
@@ -597,8 +596,7 @@ static int do_accept_unix(int acc_sock, int *sock)
*/
goto redoit;
}
- fprintf(stderr, "errno=%d ", errno);
- perror("accept");
+ BIO_printf(bio_err, "accept errno=%d, %s\n", errno, strerror(errno));
return (0);
}
diff --git a/apps/s_time.c b/apps/s_time.c
index 4f56174d65..ef95b5ada6 100644
--- a/apps/s_time.c
+++ b/apps/s_time.c
@@ -238,7 +238,7 @@ int s_time_main(int argc, char **argv)
if (cipher == NULL)
cipher = getenv("SSL_CIPHER");
if (cipher == NULL) {
- fprintf(stderr, "No CIPHER specified\n");
+ BIO_printf(bio_err, "No CIPHER specified\n");
goto end;
}
@@ -336,7 +336,7 @@ int s_time_main(int argc, char **argv)
/* Get an SSL object so we can reuse the session id */
if ((scon = doConnection(NULL, host, ctx)) == NULL) {
- fprintf(stderr, "Unable to get connection\n");
+ BIO_printf(bio_err, "Unable to get connection\n");
goto end;
}
diff --git a/apps/speed.c b/apps/speed.c
index 45a060fd14..1a3027b497 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -1649,7 +1649,7 @@ int speed_main(int argc, char **argv)
if (!
(EVP_CIPHER_flags(evp_cipher) &
EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK)) {
- fprintf(stderr, "%s is not multi-block capable\n",
+ BIO_printf(bio_err, "%s is not multi-block capable\n",
OBJ_nid2ln(evp_cipher->nid));
goto end;
}
@@ -2290,11 +2290,11 @@ static int do_multi(int multi)
fds = malloc(sizeof(*fds) * multi);
for (n = 0; n < multi; ++n) {
if (pipe(fd) == -1) {
- fprintf(stderr, "pipe failure\n");
+ BIO_printf(bio_err, "pipe failure\n");
exit(1);
}
fflush(stdout);
- fflush(stderr);
+ (void)BIO_flush(bio_err);
if (fork()) {
close(fd[1]);
fds[n] = fd[0];
@@ -2302,7 +2302,7 @@ static int do_multi(int multi)
close(fd[0]);
close(1);
if (dup(fd[1]) == -1) {
- fprintf(stderr, "dup failed\n");
+ BIO_printf(bio_err, "dup failed\n");
exit(1);
}
close(fd[1]);
@@ -2326,7 +2326,7 @@ static int do_multi(int multi)
if (p)
*p = '\0';
if (buf[0] != '+') {
- fprintf(stderr, "Don't understand line '%s' from child %d\n",
+ BIO_printf(bio_err, "Don't understand line '%s' from child %d\n",
buf, n);
continue;
}
@@ -2428,7 +2428,7 @@ static int do_multi(int multi)
else if (strncmp(buf, "+H:", 3) == 0) {
;
} else
- fprintf(stderr, "Unknown type '%s' from child %d\n", buf, n);
+ BIO_printf(bio_err, "Unknown type '%s' from child %d\n", buf, n);
}
fclose(f);