[FFmpeg-cvslog] avcodec/h264_parser: saturate dts a bit
Michael Niedermayer
git at videolan.org
Fri Dec 22 01:53:13 EET 2023
ffmpeg | branch: release/4.4 | Michael Niedermayer <michael at niedermayer.cc> | Sun Oct 1 00:07:20 2023 +0200| [14e6423dfd3ede8b5978967be46f296eed10dcc8] | committer: Michael Niedermayer
avcodec/h264_parser: saturate dts a bit
Fixes: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6112289464123392
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 7fedbc7606614cc1a6224effa8df762b6883bdc4)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=14e6423dfd3ede8b5978967be46f296eed10dcc8
---
libavcodec/h264_parser.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index aacd44cf3b..7cb7733116 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -625,10 +625,10 @@ static int h264_parse(AVCodecParserContext *s,
int64_t num = avctx->time_base.num * (int64_t)avctx->pkt_timebase.den;
if (s->dts != AV_NOPTS_VALUE) {
// got DTS from the stream, update reference timestamp
- p->reference_dts = s->dts - av_rescale(s->dts_ref_dts_delta, num, den);
+ p->reference_dts = av_sat_sub64(s->dts, av_rescale(s->dts_ref_dts_delta, num, den));
} else if (p->reference_dts != AV_NOPTS_VALUE) {
// compute DTS based on reference timestamp
- s->dts = p->reference_dts + av_rescale(s->dts_ref_dts_delta, num, den);
+ s->dts = av_sat_add64(p->reference_dts, av_rescale(s->dts_ref_dts_delta, num, den));
}
if (p->reference_dts != AV_NOPTS_VALUE && s->pts == AV_NOPTS_VALUE)
More information about the ffmpeg-cvslog
mailing list