[FFmpeg-devel] [PATCH 2/4] mov: check for positive sample->size

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Sun May 24 00:04:23 CEST 2015


Without this the mov demuxer can return a large number of empty packets.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 libavformat/mov.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f6f07be..a6290d1 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4260,6 +4260,11 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
         sample->size = FFMIN(sample->size, (mov->next_root_atom - sample->pos));
     }
 
+    if (!sample->size) {
+        av_log(s, AV_LOG_ERROR, "sample size is zero\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     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",
-- 
2.1.4


More information about the ffmpeg-devel mailing list