Skip to content

Commit

Permalink
[core] Fix: check incoming ACK value in case of a rogue peer
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Małecki authored and maxsharabayko committed Nov 24, 2020
1 parent c2f9316 commit 30ca93f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions srtcore/core.cpp
Expand Up @@ -8358,6 +8358,18 @@ void CUDT::processCtrlAck(const CPacket &ctrlpkt, const steady_clock::time_point
const int32_t* ackdata = (const int32_t*)ctrlpkt.m_pcData;
const int32_t ackdata_seqno = ackdata[ACKD_RCVLASTACK];

// Check the value of ACK in case when it was some rogue peer
if (ackdata_seqno < 0)
{
// This embraces all cases when the most significant bit is set,
// as the variable is of a signed type. So, SRT_SEQNO_NONE is
// included, but it also triggers for any other kind of invalid value.
// This check MUST BE DONE before making any operation on this number.
LOGC(inlog.Error, log << CONID() << "ACK: IPE/EPE: received invalid ACK value: " << ackdata_seqno
<< " " << std::hex << ackdata_seqno << " (IGNORED)");
return;
}

const bool isLiteAck = ctrlpkt.getLength() == (size_t)SEND_LITE_ACK;
HLOGC(inlog.Debug,
log << CONID() << "ACK covers: " << m_iSndLastDataAck << " - " << ackdata_seqno << " [ACK=" << m_iSndLastAck
Expand Down

0 comments on commit 30ca93f

Please sign in to comment.