[FFmpeg-devel] [PATCH 1/3] flvdec: Check index for being valid Fixes seeking in Enigma_Principles_of_Lust.flv

Michael Niedermayer michaelni at gmx.at
Fri Dec 30 01:38:39 CET 2011


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavformat/flvdec.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 57ef061..2e50320 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -200,7 +200,16 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream
         }
     }
 
-    if (timeslen == fileposlen && fileposlen && max_pos <= filepositions[0]) {
+    if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) {
+        int64_t dts, size0, size1;
+        avio_seek(ioc, filepositions[1]-4, SEEK_SET);
+        size0 = avio_rb32(ioc);
+                avio_r8(ioc);
+        size1 = avio_rb24(ioc);
+        dts   = avio_rb24(ioc);
+        dts  |= avio_r8(ioc) << 24;
+        if (size0 > filepositions[1] || FFABS(dts - times[1]*1000)>5000)
+            goto finish;
          for(i = 0; i < timeslen; i++)
              av_add_index_entry(vstream, filepositions[i], times[i]*1000, 0, 0, AVINDEX_KEYFRAME);
     } else
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list