[FFmpeg-cvslog] avformat/sbgdec: Check for negative duration or un-representable end pts

Michael Niedermayer git at videolan.org
Mon Oct 30 02:11:16 EET 2023


ffmpeg | branch: release/5.1 | Michael Niedermayer <michael at niedermayer.cc> | Sun Oct  1 00:30:39 2023 +0200| [30b3f2712d585fe2c77daa1bb073341c4d1aa5d9] | committer: Michael Niedermayer

avformat/sbgdec: Check for negative duration or un-representable end pts

Fixes: signed integer overflow: 9230955872951340 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6330481893572608

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george at nsup.org>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 9b00b5734d9868971cb6e6cda0f3b8eeed93be9e)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/sbgdec.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index 9f1d399361..1ef50e1598 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -1461,6 +1461,13 @@ static av_cold int sbg_read_header(AVFormatContext *avf)
     st->duration      = script.end_ts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE :
                         av_rescale(script.end_ts - script.start_ts,
                                    sbg->sample_rate, AV_TIME_BASE);
+
+    if (st->duration != AV_NOPTS_VALUE && (
+        st->duration < 0 || st->start_time > INT64_MAX - st->duration)) {
+        r = AVERROR_INVALIDDATA;
+        goto fail;
+    }
+
     sti->cur_dts      = st->start_time;
     r = encode_intervals(&script, st->codecpar, &inter);
     if (r < 0)



More information about the ffmpeg-cvslog mailing list