avformat/tty: Check avio_size()

Fixes: CID1220824 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 41745e550a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2024-07-11 21:05:20 +02:00
parent cedd68972d
commit ec4e963318
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64
1 changed files with 8 additions and 5 deletions

View File

@ -113,13 +113,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: