提交 6c3e1144 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Avoid possible segfault if RemoteBitrateEstimator generates a report with empty ssrcs.

上级 0c9204ba
...@@ -45,6 +45,7 @@ namespace RTC ...@@ -45,6 +45,7 @@ namespace RTC
if (Utils::Byte::Get4Bytes(data, 8) != uniqueIdentifier) if (Utils::Byte::Get4Bytes(data, 8) != uniqueIdentifier)
{ {
MS_WARN_TAG(rtcp, "invalid unique indentifier in REMB packet"); MS_WARN_TAG(rtcp, "invalid unique indentifier in REMB packet");
this->isCorrect = false; this->isCorrect = false;
return; return;
} }
...@@ -70,17 +71,14 @@ namespace RTC ...@@ -70,17 +71,14 @@ namespace RTC
(numSsrcs * sizeof(uint32_t))) (numSsrcs * sizeof(uint32_t)))
{ {
MS_WARN_TAG( MS_WARN_TAG(
rtcp, rtcp, "invalid payload size (%zu bytes) for the given number of ssrcs (%zu)", len, numSsrcs);
"invalid payload size: %zu for the given number of ssrcs: "
"%zu",
len,
numSsrcs);
this->isCorrect = false; this->isCorrect = false;
return; return;
} }
size_t index{ 16 }; size_t index{ 16 };
this->ssrcs.reserve(numSsrcs); this->ssrcs.reserve(numSsrcs);
for (size_t n{ 0 }; n < numSsrcs; ++n) for (size_t n{ 0 }; n < numSsrcs; ++n)
{ {
...@@ -130,9 +128,11 @@ namespace RTC ...@@ -130,9 +128,11 @@ namespace RTC
MS_DUMP("<FeedbackPsRembPacket>"); MS_DUMP("<FeedbackPsRembPacket>");
FeedbackPsPacket::Dump(); FeedbackPsPacket::Dump();
MS_DUMP("\t bitrate (bps): %" PRIu64, this->bitrate); MS_DUMP(" bitrate (bps): %" PRIu64, this->bitrate);
for (auto ssrc : this->ssrcs) for (auto ssrc : this->ssrcs)
MS_DUMP("\t ssrc: %" PRIu32, ssrc); {
MS_DUMP(" ssrc: %" PRIu32, ssrc);
}
MS_DUMP("</FeedbackPsRembPacket>"); MS_DUMP("</FeedbackPsRembPacket>");
} }
} // namespace RTCP } // namespace RTCP
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "Utils.hpp" #include "Utils.hpp"
#include "RTC/RTCP/FeedbackPsRemb.hpp" #include "RTC/RTCP/FeedbackPsRemb.hpp"
#include <cmath> // std::pow() #include <cmath> // std::pow()
#include <iterator> // std::ostream_iterator<>() #include <iterator> // std::ostream_iterator
#include <sstream> // std::ostringstream #include <sstream> // std::ostringstream
/* Consts. */ /* Consts. */
...@@ -1228,8 +1228,11 @@ namespace RTC ...@@ -1228,8 +1228,11 @@ namespace RTC
{ {
std::ostringstream ssrcsStream; std::ostringstream ssrcsStream;
std::copy(ssrcs.begin(), ssrcs.end() - 1, std::ostream_iterator<int>(ssrcsStream, ",")); if (!ssrcs.empty())
ssrcsStream << ssrcs.back(); {
std::copy(ssrcs.begin(), ssrcs.end() - 1, std::ostream_iterator<uint32_t>(ssrcsStream, ","));
ssrcsStream << ssrcs.back();
}
MS_DEBUG_TAG( MS_DEBUG_TAG(
rbe, rbe,
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <uv.h> #include <uv.h>
#include <cctype> // isprint() #include <cctype> // isprint()
#include <cerrno> #include <cerrno>
#include <iterator> // std::ostream_iterator
#include <sstream> // std::ostringstream
#include <unistd.h> // close() #include <unistd.h> // close()
extern "C" { extern "C" {
#include <getopt.h> #include <getopt.h>
...@@ -180,6 +182,7 @@ void Settings::PrintConfiguration() ...@@ -180,6 +182,7 @@ void Settings::PrintConfiguration()
MS_TRACE(); MS_TRACE();
std::vector<std::string> logTags; std::vector<std::string> logTags;
std::ostringstream logTagsStream;
if (Settings::configuration.logTags.info) if (Settings::configuration.logTags.info)
logTags.emplace_back("info"); logTags.emplace_back("info");
...@@ -198,16 +201,20 @@ void Settings::PrintConfiguration() ...@@ -198,16 +201,20 @@ void Settings::PrintConfiguration()
if (Settings::configuration.logTags.rtx) if (Settings::configuration.logTags.rtx)
logTags.emplace_back("rtx"); logTags.emplace_back("rtx");
if (!logTags.empty())
{
std::copy(
logTags.begin(), logTags.end() - 1, std::ostream_iterator<std::string>(logTagsStream, ","));
logTagsStream << logTags.back();
}
MS_DEBUG_TAG(info, "<configuration>"); MS_DEBUG_TAG(info, "<configuration>");
MS_DEBUG_TAG( MS_DEBUG_TAG(
info, info,
" logLevel : \"%s\"", " logLevel : \"%s\"",
Settings::logLevel2String[Settings::configuration.logLevel].c_str()); Settings::logLevel2String[Settings::configuration.logLevel].c_str());
for (auto& tag : logTags) MS_DEBUG_TAG(info, " logTags : \"%s\"", logTagsStream.str().c_str());
{
MS_DEBUG_TAG(info, " logTag : \"%s\"", tag.c_str());
}
if (Settings::configuration.hasIPv4) if (Settings::configuration.hasIPv4)
{ {
MS_DEBUG_TAG(info, " rtcIPv4 : \"%s\"", Settings::configuration.rtcIPv4.c_str()); MS_DEBUG_TAG(info, " rtcIPv4 : \"%s\"", Settings::configuration.rtcIPv4.c_str());
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论