diff options
author | Tomas Mraz <tmraz@fedoraproject.org> | 2019-09-12 12:27:36 +0200 |
---|---|---|
committer | Tomas Mraz <tmraz@fedoraproject.org> | 2019-09-12 16:37:46 +0200 |
commit | 6beb8b39ba8e4cb005c1fcd2586ba19e17f04b95 (patch) | |
tree | 48834e4e118c500f1c3f5e5cb2451fce0f519776 /crypto/comp | |
parent | Travis and Appveyor: use HARNESS_VERBOSE_FAILURE rather than HARNESS_VERBOSE (diff) | |
download | openssl-6beb8b39ba8e4cb005c1fcd2586ba19e17f04b95.tar.xz openssl-6beb8b39ba8e4cb005c1fcd2586ba19e17f04b95.zip |
BIO_f_zlib: Properly handle BIO_CTRL_PENDING and BIO_CTRL_WPENDING calls.
There can be data to write in output buffer and data to read that were
not yet read in the input stream.
Fixes #9866
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9877)
Diffstat (limited to 'crypto/comp')
-rw-r--r-- | crypto/comp/c_zlib.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c index 78219f202d..1dd7d67998 100644 --- a/crypto/comp/c_zlib.c +++ b/crypto/comp/c_zlib.c @@ -598,6 +598,28 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr) BIO_copy_next_retry(b); break; + case BIO_CTRL_WPENDING: + if (ctx->obuf == NULL) + return 0; + + if (ctx->odone) { + ret = ctx->ocount; + } else { + ret = ctx->ocount; + if (ret == 0) + /* Unknown amount pending but we are not finished */ + ret = 1; + } + if (ret == 0) + ret = BIO_ctrl(next, cmd, num, ptr); + break; + + case BIO_CTRL_PENDING: + ret = ctx->zin.avail_in; + if (ret == 0) + ret = BIO_ctrl(next, cmd, num, ptr); + break; + default: ret = BIO_ctrl(next, cmd, num, ptr); break; |