summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-05-24 18:15:57 +0200
committerTomas Mraz <tomas@openssl.org>2021-05-26 17:18:34 +0200
commit0800318a0c1f80ed838838951b0478cb977d40a6 (patch)
tree686267909ca13431b484c0c8e5a9a09fcc1b4537 /apps
parent022411112dd19420f0df51818322a216d914a0fb (diff)
Deprecate old style BIO callback calls
New style BIO_debug_callback_ex() function added to provide replacement for BIO_debug_callback(). Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15440)
Diffstat (limited to 'apps')
-rw-r--r--apps/dgst.c2
-rw-r--r--apps/enc.c10
-rw-r--r--apps/include/s_apps.h4
-rw-r--r--apps/lib/s_cb.c27
-rw-r--r--apps/s_client.c2
-rw-r--r--apps/s_server.c6
6 files changed, 30 insertions, 21 deletions
diff --git a/apps/dgst.c b/apps/dgst.c
index 0fa668511a..e39d645cb8 100644
--- a/apps/dgst.c
+++ b/apps/dgst.c
@@ -248,7 +248,7 @@ int dgst_main(int argc, char **argv)
goto end;
if (debug) {
- BIO_set_callback(in, BIO_debug_callback);
+ BIO_set_callback_ex(in, BIO_debug_callback_ex);
/* needed for windows 3.1 */
BIO_set_callback_arg(in, (char *)bio_err);
}
diff --git a/apps/enc.c b/apps/enc.c
index 32ed08d943..cda0022ebb 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -389,8 +389,8 @@ int enc_main(int argc, char **argv)
goto end;
if (debug) {
- BIO_set_callback(in, BIO_debug_callback);
- BIO_set_callback(out, BIO_debug_callback);
+ BIO_set_callback_ex(in, BIO_debug_callback_ex);
+ BIO_set_callback_ex(out, BIO_debug_callback_ex);
BIO_set_callback_arg(in, (char *)bio_err);
BIO_set_callback_arg(out, (char *)bio_err);
}
@@ -403,7 +403,7 @@ int enc_main(int argc, char **argv)
if ((bzl = BIO_new(BIO_f_zlib())) == NULL)
goto end;
if (debug) {
- BIO_set_callback(bzl, BIO_debug_callback);
+ BIO_set_callback_ex(bzl, BIO_debug_callback_ex);
BIO_set_callback_arg(bzl, (char *)bio_err);
}
if (enc)
@@ -417,7 +417,7 @@ int enc_main(int argc, char **argv)
if ((b64 = BIO_new(BIO_f_base64())) == NULL)
goto end;
if (debug) {
- BIO_set_callback(b64, BIO_debug_callback);
+ BIO_set_callback_ex(b64, BIO_debug_callback_ex);
BIO_set_callback_arg(b64, (char *)bio_err);
}
if (olb64)
@@ -579,7 +579,7 @@ int enc_main(int argc, char **argv)
}
if (debug) {
- BIO_set_callback(benc, BIO_debug_callback);
+ BIO_set_callback_ex(benc, BIO_debug_callback_ex);
BIO_set_callback_arg(benc, (char *)bio_err);
}
diff --git a/apps/include/s_apps.h b/apps/include/s_apps.h
index a5e9762aed..18dbd50d31 100644
--- a/apps/include/s_apps.h
+++ b/apps/include/s_apps.h
@@ -36,8 +36,8 @@ int init_client(int *sock, const char *host, const char *port,
int should_retry(int i);
void do_ssl_shutdown(SSL *ssl);
-long bio_dump_callback(BIO *bio, int cmd, const char *argp,
- int argi, long argl, long ret);
+long bio_dump_callback(BIO *bio, int cmd, const char *argp, size_t len,
+ int argi, long argl, int ret, size_t *processed);
void apps_ssl_info_callback(const SSL *s, int where, int ret);
void msg_cb(int write_p, int version, int content_type, const void *buf,
diff --git a/apps/lib/s_cb.c b/apps/lib/s_cb.c
index e3d9ec1916..ba883996ba 100644
--- a/apps/lib/s_cb.c
+++ b/apps/lib/s_cb.c
@@ -415,8 +415,8 @@ int ssl_print_tmp_key(BIO *out, SSL *s)
return 1;
}
-long bio_dump_callback(BIO *bio, int cmd, const char *argp,
- int argi, long argl, long ret)
+long bio_dump_callback(BIO *bio, int cmd, const char *argp, size_t len,
+ int argi, long argl, int ret, size_t *processed)
{
BIO *out;
@@ -425,14 +425,23 @@ long bio_dump_callback(BIO *bio, int cmd, const char *argp,
return ret;
if (cmd == (BIO_CB_READ | BIO_CB_RETURN)) {
- BIO_printf(out, "read from %p [%p] (%lu bytes => %ld (0x%lX))\n",
- (void *)bio, (void *)argp, (unsigned long)argi, ret, ret);
- BIO_dump(out, argp, (int)ret);
- return ret;
+ if (ret > 0 && processed != NULL) {
+ BIO_printf(out, "read from %p [%p] (%zu bytes => %zu (0x%zX))\n",
+ (void *)bio, (void *)argp, len, *processed, *processed);
+ BIO_dump(out, argp, (int)*processed);
+ } else {
+ BIO_printf(out, "read from %p [%p] (%zu bytes => %d)\n",
+ (void *)bio, (void *)argp, len, ret);
+ }
} else if (cmd == (BIO_CB_WRITE | BIO_CB_RETURN)) {
- BIO_printf(out, "write to %p [%p] (%lu bytes => %ld (0x%lX))\n",
- (void *)bio, (void *)argp, (unsigned long)argi, ret, ret);
- BIO_dump(out, argp, (int)ret);
+ if (ret > 0 && processed != NULL) {
+ BIO_printf(out, "write to %p [%p] (%zu bytes => %zu (0x%zX))\n",
+ (void *)bio, (void *)argp, len, *processed, *processed);
+ BIO_dump(out, argp, (int)*processed);
+ } else {
+ BIO_printf(out, "write to %p [%p] (%zu bytes => %d)\n",
+ (void *)bio, (void *)argp, len, ret);
+ }
}
return ret;
}
diff --git a/apps/s_client.c b/apps/s_client.c
index 1754d3e1a4..85789eed23 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -2076,7 +2076,7 @@ int s_client_main(int argc, char **argv)
}
if (c_debug) {
- BIO_set_callback(sbio, bio_dump_callback);
+ BIO_set_callback_ex(sbio, bio_dump_callback);
BIO_set_callback_arg(sbio, (char *)bio_c_out);
}
if (c_msg) {
diff --git a/apps/s_server.c b/apps/s_server.c
index 0ff436be1e..644fe1a905 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -2392,7 +2392,7 @@ static int sv_body(int s, int stype, int prot, unsigned char *context)
/* SSL_set_fd(con,s); */
if (s_debug) {
- BIO_set_callback(SSL_get_rbio(con), bio_dump_callback);
+ BIO_set_callback_ex(SSL_get_rbio(con), bio_dump_callback);
BIO_set_callback_arg(SSL_get_rbio(con), (char *)bio_s_out);
}
if (s_msg) {
@@ -3025,7 +3025,7 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
#endif
if (s_debug) {
- BIO_set_callback(SSL_get_rbio(con), bio_dump_callback);
+ BIO_set_callback_ex(SSL_get_rbio(con), bio_dump_callback);
BIO_set_callback_arg(SSL_get_rbio(con), (char *)bio_s_out);
}
if (s_msg) {
@@ -3429,7 +3429,7 @@ static int rev_body(int s, int stype, int prot, unsigned char *context)
#endif
if (s_debug) {
- BIO_set_callback(SSL_get_rbio(con), bio_dump_callback);
+ BIO_set_callback_ex(SSL_get_rbio(con), bio_dump_callback);
BIO_set_callback_arg(SSL_get_rbio(con), (char *)bio_s_out);
}
if (s_msg) {