aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-10-12 20:55:25 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-11-18 02:35:03 +0100
commit77d35ab73435a9c847f387621f066c1f98733580 (patch)
tree615ebc4ca849288d916357a28bdff5a1afe2dded /libavformat
parent9181ecd2e60285136f77c655d87ec7538cdfded1 (diff)
downloadffmpeg-77d35ab73435a9c847f387621f066c1f98733580.tar.gz
avformat/utils: Never store negative values in last_IP_duration
Fixes: integer overflow compute_pkt_fields() Fixes: compute_pkt_usan Reported-by: Thomas Guilbert <tguilbert@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 079d1a7175c4b881631a7e7f449c4c13b761cdeb) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8cdad78659..dc867a96a3 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1293,7 +1293,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
/* This is tricky: the dts must be incremented by the duration
* of the frame we are displaying, i.e. the last I- or P-frame. */
- if (st->last_IP_duration == 0)
+ if (st->last_IP_duration == 0 && (uint64_t)pkt->duration <= INT32_MAX)
st->last_IP_duration = pkt->duration;
if (pkt->dts != AV_NOPTS_VALUE)
st->cur_dts = pkt->dts + st->last_IP_duration;
@@ -1305,7 +1305,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
next_pts != AV_NOPTS_VALUE)
pkt->pts = next_dts;
- st->last_IP_duration = pkt->duration;
+ if ((uint64_t)pkt->duration <= INT32_MAX)
+ st->last_IP_duration = pkt->duration;
st->last_IP_pts = pkt->pts;
/* Cannot compute PTS if not present (we can compute it only
* by knowing the future. */