Skip to content
Snippets Groups Projects
Commit 7a46d091 authored by Adrien Béraud's avatar Adrien Béraud Committed by Philippe Gorley
Browse files

TlsSession: prevent SEGFAULT in recvRaw


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

Change-Id: I10790755a32a8fe7f26afea19691aa2ff6fa63be
Reviewed-by: default avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent 4d3e7c19
Branches
Tags
No related merge requests found
......@@ -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));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment