Use bio_err not stderr in apps.

Except for VMS startup code.

Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
Rich Salz 2015-06-04 14:26:55 -04:00 committed by Rich Salz
parent 51b04a6117
commit 7768e116dc
7 changed files with 32 additions and 34 deletions

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);