[FFmpeg-devel] [PATCH] improved lavf/mm.c probe

Reimar Döffinger Reimar.Doeffinger
Mon Sep 14 19:33:39 CEST 2009


Hello,
this checks a few more things like fps, width, height and the type of
the second chunk. It looks a bit ugly though. Comments?
Index: libavformat/mm.c
===================================================================
--- libavformat/mm.c    (revision 19839)
+++ libavformat/mm.c    (working copy)
@@ -58,11 +58,23 @@
 
 static int mm_probe(AVProbeData *p)
 {
+    int len, type, fps, w, h;
+    if (p->buf_size < MM_HEADER_LEN_AV + MM_PREAMBLE_SIZE)
+        return 0;
     /* the first chunk is always the header */
     if (AV_RL16(&p->buf[0]) != MM_TYPE_HEADER)
         return 0;
-    if (AV_RL32(&p->buf[2]) != MM_HEADER_LEN_V && AV_RL32(&p->buf[2])
     != MM_HEADER_LEN_AV)
+    len = AV_RL32(&p->buf[2]);
+    if (len != MM_HEADER_LEN_V && len != MM_HEADER_LEN_AV)
         return 0;
+    fps = AV_RL16(&p->buf[8]);
+    w = AV_RL16(&p->buf[12]);
+    h = AV_RL16(&p->buf[14]);
+    if (!fps || fps > 16 || !w || w > 2048 || !h || h > 2048)
+        return 0;
+    type = AV_RL16(&p->buf[len]);
+    if (!type || type > 0x31)
+        return 0;
 
     /* only return half certainty since this check is a bit sketchy */
     return AVPROBE_SCORE_MAX / 2;




More information about the ffmpeg-devel mailing list