From cd7b0a943b53c9196b6ca007731dff5a66d8fd00 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 20 Sep 2026 23:50:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(codec):=20=E4=BF=AE=E5=A4=8DH264=20RTP?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E4=B8=AD=E7=9A=84=E7=BC=93=E5=86=B2=E5=8C=BA?= =?UTF-8?q?=E8=AF=BB=E8=B6=8A=E7=95=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ext-codec/H264Rtp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext-codec/H264Rtp.cpp b/ext-codec/H264Rtp.cpp index 95967191..46bb9d3a 100644 --- a/ext-codec/H264Rtp.cpp +++ b/ext-codec/H264Rtp.cpp @@ -107,7 +107,8 @@ bool H264RtpDecoder::unpackStapA(const RtpPacket::Ptr &rtp, const uint8_t *ptr, auto end = ptr + size; while (ptr + 2 < end) { uint16_t len = (ptr[0] << 8) | ptr[1]; - if (!len || ptr + len > end) { + // 需将随后的 2 字节 NALU size 字段计入边界,否则 ptr += 2 后读取 len 字节可越界最多 2 字节 + if (!len || ptr + 2 + len > end) { WarnL << "invalid rtp data size:" << len << ",rtp:\r\n" << rtp->dumpString(); _gop_dropped = true; break;