summaryrefslogtreecommitdiff
path: root/libavformat/mov.c
diff options
context:
space:
mode:
authorAlexandre Sicard <alexandre.sicard@smartjog.com>2013-06-11 11:06:38 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-06-12 00:51:38 +0200
commitb1d61eb7aaaef84391130b6f5e83942cc829a8c8 (patch)
tree2d0d4f3a252ef4fd665b9fd452e8ac6e6acf81a2 /libavformat/mov.c
parentdf084adbf7300b819460f06302a04ca103020feb (diff)
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: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r--libavformat/mov.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 407b52f342..5c61f6c718 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -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",