summaryrefslogtreecommitdiff
path: root/libavformat/mm.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-09-15 09:21:29 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-09-15 09:21:29 +0000
commit5837e4ca3362bf1d182c1d49a9faff3f4910d00a (patch)
tree88e6cc9050bb0c26bc70a3a565ae3283da4d654b /libavformat/mm.c
parent97e078087b08cbca22bd1c8f373653e559616b42 (diff)
Vastly improved mm_probe function, passes probetest.
Originally committed as revision 19851 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mm.c')
-rw-r--r--libavformat/mm.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/libavformat/mm.c b/libavformat/mm.c
index 6c621ab493..993aebf32f 100644
--- a/libavformat/mm.c
+++ b/libavformat/mm.c
@@ -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 */