avformat/webpenc: Check filesize in trailer

not sure this is possible

Fixes: CID1604446 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2024-07-11 22:13:42 +02:00
parent be30913538
commit 7734c583f7
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -190,7 +190,7 @@ static int webp_write_trailer(AVFormatContext *s)
if (!ret) { if (!ret) {
filesize = avio_tell(s->pb); filesize = avio_tell(s->pb);
if (avio_seek(s->pb, 4, SEEK_SET) == 4) { if (filesize >= 8 && avio_seek(s->pb, 4, SEEK_SET) == 4) {
avio_wl32(s->pb, filesize - 8); avio_wl32(s->pb, filesize - 8);
// Note: without the following, avio only writes 8 bytes to the file. // Note: without the following, avio only writes 8 bytes to the file.
avio_seek(s->pb, filesize, SEEK_SET); avio_seek(s->pb, filesize, SEEK_SET);