Commit 7a46d091 authored by Adrien Béraud's avatar Adrien Béraud Committed by Philippe Gorley

TlsSession: prevent SEGFAULT in recvRaw

Set EAGAIN if rxQueue_ is empty to avoid reading
an invalid queue front.

Change-Id: I10790755a32a8fe7f26afea19691aa2ff6fa63be
Reviewed-by: Philippe Gorley's avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent 4d3e7c19
......@@ -622,6 +622,11 @@ TlsSession::TlsSessionImpl::recvRaw(void* buf, size_t size)
return -1;
}
if (rxQueue_.empty()) {
gnutls_transport_set_errno(session_, EAGAIN);
return -1;
}
const auto& pkt = rxQueue_.front();
const std::size_t count = std::min(pkt.size(), size);
std::copy_n(pkt.begin(), count, reinterpret_cast<ValueType*>(buf));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment