Commit d353ea87b7 for ffmpeg

commit d353ea87b74abb48adbb0715927d401d8828f918
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Thu Oct 15 04:34:32 2026 +0200

    avformat/sctp: return AVERROR_EOF when the peer closes the association

    Fixes: WoBBcuySgSTx
    Fixes: swarm-sctp_read-returns-2-on-graceful-close-never-signalling-EOF-2a7ba0
    Endless loop Replicated through UnModified FFmpeg

    Found-by: zhang xingxing <2388969553@qq.com>
    The report suggested not adding the stream id size when recvmsg() returns 0.
    The case without max_streams was found during triage of the report.

    Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

diff --git a/libavformat/sctp.c b/libavformat/sctp.c
index 0efac12d96..ed132f1851 100644
--- a/libavformat/sctp.c
+++ b/libavformat/sctp.c
@@ -309,17 +309,19 @@ static int sctp_read(URLContext *h, uint8_t *buf, int size)
     }

     if (s->max_streams) {
-        if (size < 2)
+        if (size <= 2)
             return AVERROR(EINVAL);

         /*StreamId is introduced as a 2byte code into the stream*/
         struct sctp_sndrcvinfo info = { 0 };
         ret = ff_sctp_recvmsg(s->fd, buf + 2, size - 2, NULL, 0, &info, 0);
         AV_WB16(buf, info.sinfo_stream);
-        ret = ret < 0 ? ret : ret + 2;
+        ret = ret <= 0 ? ret : ret + 2;
     } else
         ret = recv(s->fd, buf, size, 0);

+    if (!ret)
+        return AVERROR_EOF;
     return ret < 0 ? ff_neterrno() : ret;
 }