Skip to content

Commit

Permalink
Fixed an issue where memory could be exhausted if incorrect RTMP pack…
Browse files Browse the repository at this point in the history
…ets were continuously received
  • Loading branch information
dimiden committed Oct 8, 2024
1 parent 6a1abe0 commit 68416ae
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/projects/providers/rtmp/rtmp_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ namespace pvd
}
_acknowledgement_traffic_after_last_acked += data_length;

if ((_remained_data != nullptr) && (_remained_data->GetLength() > RTMP_MAX_PACKET_SIZE))
{
logte("The packet is ignored because the size is too large: [%d]), packet size: %zu, threshold: %d",
GetChannelId(), _remained_data->GetLength(), RTMP_MAX_PACKET_SIZE);

return false;
}

if ((_remained_data == nullptr) || _remained_data->IsEmpty())
{
_remained_data = data->Clone();
Expand All @@ -190,14 +198,6 @@ namespace pvd
_remained_data->Append(data);
}

if (_remained_data->GetLength() > RTMP_MAX_PACKET_SIZE)
{
logte("The packet is ignored because the size is too large: [%d]), packet size: %zu, threshold: %d",
GetChannelId(), _remained_data->GetLength(), RTMP_MAX_PACKET_SIZE);

return false;
}

logtp("Trying to parse data\n%s", _remained_data->Dump(_remained_data->GetLength()).CStr());

while (true)
Expand Down

0 comments on commit 68416ae

Please sign in to comment.