avformat/aviobuf: Check buf_size in ffio_ensure_seekback()

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@niedermayer.cc>
release/5.1
Michael Niedermayer 3 years ago
parent 35dc93ab44
commit c4b130e876
  1. 3
      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)

Loading…
Cancel
Save