summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2023-05-10 23:58:31 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2023-09-16 20:47:32 +0200
commit80f6e0378beae69d31f24b036a1365405dea61d1 (patch)
treef6d414f6c91d90d39be80e08498d2e9ca80c8ff8
parentb5c07a368b64a0d96abfdc8c4546e29ced67eff9 (diff)
avformat/format: Stop reading data at EOF during probing
Issue found by: Сергей Колесников Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/format.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/format.c b/libavformat/format.c
index 477ad6b43b..4738e69a1c 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -257,6 +257,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;
@@ -280,7 +281,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;
@@ -296,6 +297,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)