From b7dc4a16feb60a73ae9f54969287a2cbfac30b29 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 9 Dec 2019 16:57:04 +0100 Subject: [PATCH] Handle pending data in TLS buffers There might be more bytes left in the current TLS record, even if there is nothing on the underlying stream. Make sure we properly return this when we aren't being requested to block. --- common/rdr/TLSInStream.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/rdr/TLSInStream.cxx b/common/rdr/TLSInStream.cxx index 3e1172f..cd81f22 100644 --- a/common/rdr/TLSInStream.cxx +++ b/common/rdr/TLSInStream.cxx @@ -111,9 +111,11 @@ size_t TLSInStream::readTLS(U8* buf, size_t len, bool wait) { int n; - n = in->check(1, 1, wait); - if (n == 0) - return 0; + if (gnutls_record_check_pending(session) == 0) { + n = in->check(1, 1, wait); + if (n == 0) + return 0; + } n = gnutls_record_recv(session, (void *) buf, len); if (n == GNUTLS_E_INTERRUPTED || n == GNUTLS_E_AGAIN)