Commit b1d61eb7 authored by Alexandre Sicard's avatar Alexandre Sicard Committed by Michael Niedermayer

avformat/mov: ignore samples overflowing next_root_atom

This fixes #2657.
ISML movies produced by Microsoft Expression Encoder 4 seem to have invalid
sample entries in their trun/tfhd for data tracks. As a result, too much bytes
are read for these tracks to the point that next_root_atom can go out of
buffer, which makes the encoding fail if the input is not seekable.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent df084adb
......@@ -3276,6 +3276,11 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
/* must be done just before reading, to avoid infinite loop on sample */
sc->current_sample++;
if (mov->next_root_atom) {
sample->pos = FFMIN(sample->pos, mov->next_root_atom);
sample->size = FFMIN(sample->size, (mov->next_root_atom - sample->pos));
}
if (st->discard != AVDISCARD_ALL) {
if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment