Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] make sure TTL will not drop packets over last block #2005

Merged
14 changes: 13 additions & 1 deletion srtcore/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,19 @@ int CSndBuffer::readData(const int offset, srt::CPacket& w_packet, steady_clock:
// XXX Suboptimal procedure to keep the blocks identifiable
// by sequence number. Consider using some circular buffer.
for (int i = 0; i < offset; ++i)
{
if (p == m_pLastBlock)
{
LOGC(qslog.Error, log << "CSndBuffer::readData: offset " << offset << " too large!");
return 0;
}
maxsharabayko marked this conversation as resolved.
Show resolved Hide resolved
p = p->m_pNext;
}
if (p == m_pLastBlock)
{
LOGC(qslog.Error, log << "CSndBuffer::readData: offset " << offset << " too large!");
return 0;
}
#if ENABLE_HEAVY_LOGGING
const int32_t first_seq = p->m_iSeqNo;
int32_t last_seq = p->m_iSeqNo;
Expand All @@ -550,7 +562,7 @@ int CSndBuffer::readData(const int offset, srt::CPacket& w_packet, steady_clock:
w_msglen = 1;
p = p->m_pNext;
bool move = false;
while (msgno == p->getMsgSeq())
while (p != m_pLastBlock && msgno == p->getMsgSeq())
{
#if ENABLE_HEAVY_LOGGING
last_seq = p->m_iSeqNo;
Expand Down
2 changes: 1 addition & 1 deletion srtcore/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class CSndBuffer
/// @param [out] msgno message number of the packet.
/// @param [out] origintime origin time stamp of the message
/// @param [out] msglen length of the message
/// @return Actual length of data read.
/// @return Actual length of data read (return 0 if offset too large, -1 if TTL exceeded).
int readData(const int offset, srt::CPacket& w_packet, time_point& w_origintime, int& w_msglen);

/// Get the time of the last retransmission (if any) of the DATA packet.
Expand Down
7 changes: 0 additions & 7 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8882,7 +8882,6 @@ int srt::CUDT::packLostData(CPacket& w_packet, steady_clock::time_point& w_origi
int msglen;

const int payload = m_pSndBuffer->readData(offset, (w_packet), (w_origintime), (msglen));
SRT_ASSERT(payload != 0);
if (payload == -1)
{
int32_t seqpair[2];
Expand All @@ -8903,12 +8902,6 @@ int srt::CUDT::packLostData(CPacket& w_packet, steady_clock::time_point& w_origi

continue;
}
// NOTE: This is just a sanity check. Returning 0 is impossible to happen
// in case of retransmission. If the offset was a positive value, then the
// block must exist in the old blocks because it wasn't yet cut off by ACK
// and has been already recorded as sent (otherwise the peer wouldn't send
// back the loss report). May something happen here in case when the send
// loss record has been updated by the FASTREXMIT.
else if (payload == 0)
continue;

Expand Down