diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2009-09-16 04:43:33 +0000 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2009-09-16 04:43:33 +0000 |
commit | 9117213313f589627c3760bc66412c337ee2179d (patch) | |
tree | 05a3286b2f11bc3cf9377309d0a37ff66aeb34c7 /libavformat/mpc8.c | |
parent | e458dd0be099603bc023ca809b9c31a2220ef2a7 (diff) | |
download | ffmpeg-9117213313f589627c3760bc66412c337ee2179d.tar.gz |
Enhance Musepack SV8 probing code
Originally committed as revision 19874 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mpc8.c')
-rw-r--r-- | libavformat/mpc8.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index 687853bcde..284d8d1e47 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -53,9 +53,35 @@ typedef struct { static int mpc8_probe(AVProbeData *p) { - if (AV_RL32(p->buf) == TAG_MPCK) + if (p->buf_size < 16) + return 0; + if (AV_RL32(p->buf) != TAG_MPCK) + return 0; + if (p->buf[4] == 'S' && p->buf[5] == 'H') { + int size = p->buf[6]; + + if (size < 12 || size > 30) + return 0; + if (!AV_RL32(&p->buf[7])) //zero CRC is invalid + return 0; + //check whether some tag follows stream header or not + if (p->buf[4 + size] < 'A' || p->buf[4 + size] > 'Z') + return 0; + if (p->buf[5 + size] < 'A' || p->buf[5 + size] > 'Z') + return 0; + if (p->buf[6 + size] < 3) + return 0; return AVPROBE_SCORE_MAX; - return 0; + } + /* file magic number should be followed by tag name which consists of + two uppercase letters */ + if (p->buf[4] < 'A' || p->buf[4] > 'Z' || p->buf[5] < 'A' || p->buf[5] > 'Z') + return 0; + // tag size should be >= 3 + if (p->buf[6] < 3) + return 0; + // if first tag is not stream header, that's suspicious + return AVPROBE_SCORE_MAX / 4; } static inline int64_t gb_get_v(GetBitContext *gb) |