From: Matt Caswell Date: Thu, 1 Aug 2019 13:55:25 +0000 (+0100) Subject: Fix SSL_MODE_RELEASE_BUFFERS functionality X-Git-Tag: openssl-3.0.0-alpha1~1674 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8bbf63e48f27c5edaa03e6d87d969c9b6a207f3c;p=oweals%2Fopenssl.git Fix SSL_MODE_RELEASE_BUFFERS functionality At some point in the past do_ssl3_write() used to return the number of bytes written, or a value <= 0 on error. It now just returns a success/ error code and writes the number of bytes written to |tmpwrit|. The SSL_MODE_RELEASE_BUFFERS code was still looking at the return code for the number of bytes written rather than |tmpwrit|. This has the effect that the buffers are not released when they are supposed to be. Fixes #9490 Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/9505) --- diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c index 9efaf54be2..df5f6812eb 100644 --- a/ssl/record/rec_layer_s3.c +++ b/ssl/record/rec_layer_s3.c @@ -639,8 +639,9 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, size_t len, */ s->s3.empty_fragment_done = 0; - if ((i == (int)n) && s->mode & SSL_MODE_RELEASE_BUFFERS && - !SSL_IS_DTLS(s)) + if (tmpwrit == n + && (s->mode & SSL_MODE_RELEASE_BUFFERS) != 0 + && !SSL_IS_DTLS(s)) ssl3_release_write_buffer(s); *written = tot + tmpwrit;