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.
This commit is contained in:
Pierre Ossman 2019-12-09 16:57:04 +01:00 committed by Lauri Kasanen
parent 3ee909ffe6
commit b7dc4a16fe

View File

@ -111,9 +111,11 @@ size_t TLSInStream::readTLS(U8* buf, size_t len, bool wait)
{
int n;
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)