Commit 0575266957 for ffmpeg

commit 057526695752595970f5d90caa740e430911be19
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Mon Oct 19 02:15:57 2026 +0200

    avformat/rtpenc: Reject packet sizes too small for one sample

    Fixes: infinite loop
    Fixes: bz6tTr9RAaZT
    Fixes: ffmpeg -f lavfi -i sine=d=0.2 -c:a pcm_s16be -f rtp -packetsize 13 /dev/null
    Fixes: ffmpeg -f lavfi -i sine=d=0.2 -ar 8000 -c:a g726 -b:a 24k -f rtp -packetsize 14 /dev/null

    Endless loop Replicated through UnModified FFmpeg

    Found during triage of the security report TwYfznAFyatl (#22717)

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 1c91e32fbe..b42a0f2d4b 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -434,6 +434,11 @@ static int rtp_send_samples(AVFormatContext *s1,
     int aligned_samples_size = sample_size_bits/av_gcd(sample_size_bits, 8);

     max_packet_size = (s->max_payload_size / aligned_samples_size) * aligned_samples_size;
+    if (!max_packet_size) {
+        av_log(s1, AV_LOG_ERROR, "RTP max payload size too small for %d byte samples\n",
+               aligned_samples_size);
+        return AVERROR(EINVAL);
+    }
     /* Not needed, but who knows. Don't check if samples aren't an even number of bytes. */
     if ((sample_size_bits % 8) == 0 && ((8 * size) % sample_size_bits) != 0)
         return AVERROR(EINVAL);