Commit b85207c8e9 for ffmpeg
commit b85207c8e9c1c45b810530563820df0726f88c0d
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Mon Oct 19 02:14:25 2026 +0200
avformat/rtpenc: Reject packet sizes too small for the MPEG video payload header
Fixes: negative-size-param
Fixes: infinite loop
Fixes: vrmb3QRC6jK1
Fixes: swarm-Signed-integer-underflow-in-RTP-MPEG-video-packet-length-4acadd
Fixes: ffmpeg -f lavfi -i color=size=64x64:duration=1 -packetsize 13 -c:v mpeg1video -f rtp rtp://127.0.0.1:45004
Negative-size memcpy and endless loop Replicated through UnModified FFmpeg with ASAN
Found-by: zhang xingxing <2388969553@qq.com>
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 24bf6b93f8..471c988d9c 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -178,6 +178,7 @@ static int rtp_write_header(AVFormatContext *s1)
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
+ payload_header_size = 4;
break;
case AV_CODEC_ID_MPEG2TS:
if (s->max_payload_size < TS_PACKET_SIZE) {