diff mbox series

[FFmpeg-devel,1/2] avformat/format: Stop reading data at EOF during probing

Message ID 20230510215832.1001-1-michael@niedermayer.cc
State Accepted
Commit 80f6e0378beae69d31f24b036a1365405dea61d1
Headers show
Series [FFmpeg-devel,1/2] avformat/format: Stop reading data at EOF during probing | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer May 10, 2023, 9:58 p.m. UTC
Issue found by: Сергей Колесников
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/format.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Sept. 16, 2023, 5:35 p.m. UTC | #1
On Wed, May 10, 2023 at 11:58:31PM +0200, Michael Niedermayer wrote:
> Issue found by: Сергей Колесников
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/format.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/format.c b/libavformat/format.c
index 76f25ab5a6..52b814e67d 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -231,6 +231,7 @@  int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt,
     int ret = 0, probe_size, buf_offset = 0;
     int score = 0;
     int ret2;
+    int eof = 0;
 
     if (!max_probe_size)
         max_probe_size = PROBE_BUF_MAX;
@@ -254,7 +255,7 @@  int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt,
         }
     }
 
-    for (probe_size = PROBE_BUF_MIN; probe_size <= max_probe_size && !*fmt;
+    for (probe_size = PROBE_BUF_MIN; probe_size <= max_probe_size && !*fmt && !eof;
          probe_size = FFMIN(probe_size << 1,
                             FFMAX(max_probe_size, probe_size + 1))) {
         score = probe_size < max_probe_size ? AVPROBE_SCORE_RETRY : 0;
@@ -270,6 +271,7 @@  int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt,
 
             score = 0;
             ret   = 0;          /* error was end of file, nothing read */
+            eof   = 1;
         }
         buf_offset += ret;
         if (buf_offset < offset)