Browse Source

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 079d1a7175)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n3.4.5
Michael Niedermayer 7 years ago
parent
commit
d17d08035c
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      libavformat/utils.c

+ 3
- 2
libavformat/utils.c View File

@@ -1314,7 +1314,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;
@@ -1326,7 +1326,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. */


Loading…
Cancel
Save