fftools/ffmpeg_mux: Avoid signed overflow in the invalid DTS fix-up

Fixes: signed integer overflow
Fixes: YK9ibCaczocG
Fixes: C041.heic
Signed integer overflow Replicated through UnModified FFmpeg with UBSAN
Found during triage of the security report GL61hVKFlOuU
This commit is contained in:
Michael Niedermayer authored and michaelni committed 2026-10-14 17:45:20 +00:00
1 parent 25ad646c7c
commit 7b6e2f3a2a
1 file changed
+1 -3
+1 -3
View File
@@ -166,9 +166,7 @@ static int mux_fixup_ts(Muxer *mux, MuxStream *ms, AVPacket *pkt)
av_log(ost, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64", replacing by guess\n",
pkt->dts, pkt->pts);
pkt->pts =
pkt->dts = pkt->pts + pkt->dts + ms->last_mux_dts + 1
- FFMIN3(pkt->pts, pkt->dts, ms->last_mux_dts + 1)
- FFMAX3(pkt->pts, pkt->dts, ms->last_mux_dts + 1);
pkt->dts = av_clip64(ms->last_mux_dts, pkt->pts - 1, pkt->dts - 1) + 1;
}
if ((ost->type == AVMEDIA_TYPE_AUDIO || ost->type == AVMEDIA_TYPE_VIDEO || ost->type == AVMEDIA_TYPE_SUBTITLE) &&
pkt->dts != AV_NOPTS_VALUE &&