Skip to content

Commit

Permalink
[core] Check if CryptoControl exists in createSrtHandshake(..).
Browse files Browse the repository at this point in the history
If it does not, it will lead to a crash, reported in #1979.
  • Loading branch information
maxsharabayko committed Aug 9, 2021
1 parent 0fca874 commit 747f288
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,16 @@ bool srt::CUDT::createSrtHandshake(
HLOGC(cnlog.Debug,
log << "createSrtHandshake: "
<< (m_config.CryptoSecret.len > 0 ? "Agent uses ENCRYPTION" : "Peer requires ENCRYPTION"));

if (!m_pCryptoControl && (srtkm_cmd == SRT_CMD_KMREQ || srtkm_cmd == SRT_CMD_KMRSP))
{
m_RejectReason = SRT_REJ_IPE;
LOGC(cnlog.Error, log << "createSrtHandshake: IPE: need to send KM, but CryptoControl does not exist."
<< " Socket state: connected=" << boolalpha << m_bConnected << ", connecting=" << m_bConnecting
<< ", broken=" << m_bBroken << ", closing=" << m_bClosing << ".");
return false;
}

if (srtkm_cmd == SRT_CMD_KMREQ)
{
bool have_any_keys = false;
Expand Down Expand Up @@ -1753,7 +1763,6 @@ bool srt::CUDT::createSrtHandshake(
{
offset += ra_size + 1;
ra_size = fillHsExtKMRSP(p + offset - 1, kmdata, kmdata_wordsize);

}
else
{
Expand Down

0 comments on commit 747f288

Please sign in to comment.