]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mm.c
Remove an unneeded local variable.
[ffmpeg] / libavformat / mm.c
index b72c259e143617fdc5fabc38aa22a01fb8662fee..993aebf32ff12c88e86d1ff1185cf88ccd6814fb 100644 (file)
@@ -58,10 +58,22 @@ typedef struct {
 
 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 > 60 || !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 */
@@ -168,7 +180,7 @@ static int mm_read_packet(AVFormatContext *s,
             return 0;
 
         default :
-            av_log(NULL, AV_LOG_INFO, "mm: unknown chunk type 0x%x\n", type);
+            av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type);
             url_fseek(pb, length, SEEK_CUR);
         }
     }