Commit 5db1e097dc for ffmpeg

commit 5db1e097dcef7e6076093629c626b3a235307ad4
Author: Kacper Michajłow <kasper93@gmail.com>
Date:   Thu Oct 1 01:44:53 2026 +0200

    avformat/http: end a read at the end offset with EOF

    Take the end of the data as the end offset or the file size, whichever
    comes first, when telling a broken connection from the end of the data,
    so that reading up to the end offset ends with EOF instead of an I/O
    error.

    Signed-off-by: Kacper Michajłow <kasper93@gmail.com>

diff --git a/libavformat/http.c b/libavformat/http.c
index e27e80f484..82bb9be7be 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1837,6 +1837,11 @@ done:
     return err;
 }

+static uint64_t requested_end(HTTPContext *s)
+{
+    return s->end_off ? FFMIN(s->end_off, s->filesize) : s->filesize;
+}
+
 static int http_buf_read(URLContext *h, uint8_t *buf, int size)
 {
     HTTPContext *s = h->priv_data;
@@ -1962,7 +1967,7 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size)
     int conn_attempts = 1;

     if (!s->hd)
-        return s->off < s->filesize ? AVERROR(EIO) : AVERROR_EOF;
+        return s->off < requested_end(s) ? AVERROR(EIO) : AVERROR_EOF;

     if (s->end_chunked_post && !s->end_header) {
         err = http_read_header(h);
@@ -1979,7 +1984,8 @@ retry:
     read_ret = http_buf_read(h, buf, size);
     while (read_ret < 0) {
         uint64_t target = h->is_streamed ? 0 : s->off;
-        bool is_premature = s->filesize > 0 && s->off < s->filesize;
+        uint64_t file_end = requested_end(s);
+        bool is_premature = file_end > 0 && s->off < file_end;

         if (read_ret == AVERROR_EXIT)
             break;