Skip to content

Commit

Permalink
[core] Check if CryptoControl exists in craftKmResponse.
Browse files Browse the repository at this point in the history
Fixes crash #2231.
  • Loading branch information
maxsharabayko committed Apr 21, 2022
1 parent 591e320 commit 992d816
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions srtcore/core.cpp
Expand Up @@ -3908,6 +3908,15 @@ EConnectStatus srt::CUDT::craftKmResponse(uint32_t* aw_kmdata, size_t& w_kmdatas
int hs_flags = SrtHSRequest::SRT_HSTYPE_HSFLAGS::unwrap(m_ConnRes.m_iType);
if (IsSet(hs_flags, CHandShake::HS_EXT_KMREQ))
{
// m_pCryptoControl can be NULL if the socket has been closed already. See issue #2231.
if (!m_pCryptoControl)
{
m_RejectReason = SRT_REJ_IPE;
LOGC(cnlog.Error, log << "IPE: craftKmResponse needs to send KM, but CryptoControl does not exist."
<< " Socket state: connected=" << boolalpha << m_bConnected << ", connecting=" << m_bConnecting
<< ", broken=" << m_bBroken << ", opened " << m_bOpened << ", closing=" << m_bClosing << ".");
return CONN_REJECT;
}
// This is a periodic handshake update, so you need to extract the KM data from the
// first message, provided that it is there.
size_t msgsize = m_pCryptoControl->getKmMsg_size(0);
Expand Down

0 comments on commit 992d816

Please sign in to comment.