From 8f108395a5dfefbc909b12c2152dcaff08e3c450 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 26 Feb 2023 21:11:31 +0800 Subject: [PATCH] =?UTF-8?q?rtp=E6=9C=8D=E5=8A=A1=E5=99=A8=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E9=9D=9Ertp=E5=8C=85:=20#2247?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 防止非法数据干扰后续处理逻辑对rtp ssrc/pt等的绑定 --- src/Rtp/RtpProcess.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index 0673931e..993ed158 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -70,7 +70,16 @@ RtpProcess::~RtpProcess() { } } +static bool is_rtp(const char *buf) { + RtpHeader *header = (RtpHeader *)buf; + return ((header->pt < 64) || (header->pt >= 96)); +} + bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data, size_t len, const struct sockaddr *addr, uint64_t *dts_out) { + if (!is_rtp(data)) { + WarnL << "Not rtp packet"; + return false; + } if (_sock != sock) { // 第一次运行本函数 bool first = !_sock;