diff mbox series

[FFmpeg-devel,2/5] avformat/demux: Check packet duration

Message ID 20240816231504.3166080-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/5] avcodec/get_buffer: Use av_buffer_mallocz() for audio same as its done for video | expand

Commit Message

Michael Niedermayer Aug. 16, 2024, 11:15 p.m. UTC
Fixes: signed integer overflow: 24320 + 9223372036854775573 cannot be represented in type 'long'
Fixes: 71001/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-5644785744936960

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/demux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/demux.c b/libavformat/demux.c
index dc65f9ad912..bca819a09f7 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2803,7 +2803,7 @@  int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
                     av_packet_unref(pkt1);
                 break;
             }
-            if (pkt->duration > 0) {
+            if (pkt->duration > 0 && pkt->duration < INT64_MAX - sti->info->codec_info_duration) {
                 const int fields = sti->codec_desc && (sti->codec_desc->props & AV_CODEC_PROP_FIELDS);
                 if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE && pkt->pts != AV_NOPTS_VALUE && st->start_time != AV_NOPTS_VALUE && pkt->pts >= st->start_time
                     && (uint64_t)pkt->pts - st->start_time < INT64_MAX