diff options
author | Tomas Mraz <tomas@openssl.org> | 2021-05-24 18:15:57 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-05-26 17:18:34 +0200 |
commit | 0800318a0c1f80ed838838951b0478cb977d40a6 (patch) | |
tree | 686267909ca13431b484c0c8e5a9a09fcc1b4537 /apps/lib/s_cb.c | |
parent | 022411112dd19420f0df51818322a216d914a0fb (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/lib/s_cb.c')
-rw-r--r-- | apps/lib/s_cb.c | 27 |
1 files changed, 18 insertions, 9 deletions
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; } |