ffmpeg | branch: release/4.4 | Michael Niedermayer <[email protected]> | 
Wed Jun  9 21:10:32 2021 +0200| [4afa465eb33263dec1d0ef6e75ff931242447d66] | 
committer: Michael Niedermayer

avformat/utils: Avoid overflow in codec_info_duration computation for subtitles

Fixes: signed integer overflow: 9223126845747118112 - -2594073385365397472 
cannot be represented in type 'long'
Fixes: 
34936/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-6739888002170880

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <[email protected]>
(cherry picked from commit ffe4851e2359e17c4406ab05e2e31fc7ef68de95)
Signed-off-by: Michael Niedermayer <[email protected]>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4afa465eb33263dec1d0ef6e75ff931242447d66
---

 libavformat/utils.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5a70478a57..20a597a60a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3915,7 +3915,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
                 break;
             }
             if (pkt->duration) {
-                if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE && pkt->pts != 
AV_NOPTS_VALUE && st->start_time != AV_NOPTS_VALUE && pkt->pts >= 
st->start_time) {
+                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
+                ) {
                     st->internal->info->codec_info_duration = FFMIN(pkt->pts - 
st->start_time, st->internal->info->codec_info_duration + pkt->duration);
                 } else
                     st->internal->info->codec_info_duration += pkt->duration;

_______________________________________________
ffmpeg-cvslog mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to