[FFmpeg-devel] [PATCH 5/5] avformat/aviobuf: Check buf_size in ffio_ensure_seekback()
Michael Niedermayer
michael at niedermayer.cc
Mon Mar 21 01:30:56 EET 2022
buffer_size is an int
Fixes: signed integer overflow: 9223372036854775754 + 32767 cannot be represented in type 'long'
Fixes: 45691/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5263458831040512
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
libavformat/aviobuf.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 29d4bd7510..33bc3c2e20 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1062,6 +1062,9 @@ int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
if (buf_size <= s->buf_end - s->buf_ptr)
return 0;
+ if (buf_size > INT_MAX - max_buffer_size)
+ return AVERROR(EINVAL);
+
buf_size += max_buffer_size - 1;
if (buf_size + s->buf_ptr - s->buffer <= s->buffer_size || s->seekable || !s->read_packet)
--
2.17.1
More information about the ffmpeg-devel
mailing list