diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2024-07-11 21:05:20 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2024-07-21 17:02:11 +0200 |
commit | 41745e550a0274571bd9fbfb12b36ff1743d4e9c (patch) | |
tree | a80776ce8d078482c7a818e8ea91e01aee492071 | |
parent | 124a97dd8b7636fb52e042b2e85a44cce40ab5e7 (diff) | |
download | ffmpeg-41745e550a0274571bd9fbfb12b36ff1743d4e9c.tar.gz |
avformat/tty: Check avio_size()
Fixes: CID1220824 Overflowed constant
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/tty.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libavformat/tty.c b/libavformat/tty.c index 95b7200527..c3956ccf34 100644 --- a/libavformat/tty.c +++ b/libavformat/tty.c @@ -123,13 +123,16 @@ static int read_header(AVFormatContext *avctx) s->chars_per_frame = FFMAX(av_q2d(st->time_base)*s->chars_per_frame, 1); if (avctx->pb->seekable & AVIO_SEEKABLE_NORMAL) { - s->fsize = avio_size(avctx->pb); - st->duration = (s->fsize + s->chars_per_frame - 1) / s->chars_per_frame; + int64_t fsize = avio_size(avctx->pb); + if (fsize > 0) { + s->fsize = fsize; + st->duration = (s->fsize + s->chars_per_frame - 1) / s->chars_per_frame; - if (ff_sauce_read(avctx, &s->fsize, 0, 0) < 0) - efi_read(avctx, s->fsize - 51); + if (ff_sauce_read(avctx, &s->fsize, 0, 0) < 0) + efi_read(avctx, s->fsize - 51); - avio_seek(avctx->pb, 0, SEEK_SET); + avio_seek(avctx->pb, 0, SEEK_SET); + } } fail: |