[FFmpeg-cvslog] avcodec/h264_parser: saturate dts a bit
Michael Niedermayer
git at videolan.org
Mon Oct 30 02:11:40 EET 2023
ffmpeg | branch: release/5.1 | Michael Niedermayer <michael at niedermayer.cc> | Sun Oct 1 00:07:20 2023 +0200| [76ee7c771568029f55fa8806315aeb4b7f149e71] | 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=76ee7c771568029f55fa8806315aeb4b7f149e71
---
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 50810f1789..0a2451a153 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -645,10 +645,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