[FFmpeg-cvslog] avformat/tty: Check avio_size()
Michael Niedermayer
git at videolan.org
Wed Jul 24 17:50:59 EEST 2024
ffmpeg | branch: release/4.3 | Michael Niedermayer <michael at niedermayer.cc> | Thu Jul 11 21:05:20 2024 +0200| [7c6f9c872fe42238439b79aaf27c38648caabc96] | committer: Michael Niedermayer
avformat/tty: Check avio_size()
Fixes: CID1220824 Overflowed constant
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 41745e550a0274571bd9fbfb12b36ff1743d4e9c)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7c6f9c872fe42238439b79aaf27c38648caabc96
---
libavformat/tty.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/libavformat/tty.c b/libavformat/tty.c
index aed5c888c3..b47f874c60 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -122,13 +122,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:
More information about the ffmpeg-cvslog
mailing list