diff options
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r-- | libavformat/mov.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index 97857789f4..f9c4dbe5d4 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5051,6 +5051,7 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) int64_t stream_size = avio_size(pb); int64_t offset = av_sat_add64(avio_tell(pb), atom.size), pts, timestamp; uint8_t version, is_complete; + int64_t offadd; unsigned i, j, track_id, item_count; AVStream *st = NULL; AVStream *ref_st = NULL; @@ -5088,11 +5089,15 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (version == 0) { pts = avio_rb32(pb); - offset += avio_rb32(pb); + offadd= avio_rb32(pb); } else { pts = avio_rb64(pb); - offset += avio_rb64(pb); + offadd= avio_rb64(pb); } + if (av_sat_add64(offset, offadd) != offset + (uint64_t)offadd) + return AVERROR_INVALIDDATA; + + offset += (uint64_t)offadd; avio_rb16(pb); // reserved @@ -5115,6 +5120,8 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (frag_stream_info) frag_stream_info->sidx_pts = timestamp; + if (av_sat_add64(offset, size) != offset + size) + return AVERROR_INVALIDDATA; offset += size; pts += duration; } |