aboutsummaryrefslogtreecommitdiff
path: root/libavformat/xa.c
diff options
context:
space:
mode:
authorReimar Döffinger2009-09-14 19:58:51 +0000
committerReimar Döffinger2009-09-14 19:58:51 +0000
commitddbb7c9be2f8a006325ec64cd5b90e1ade5bc476 (patch)
treed28eb86e47d4f8a0bffe4b16c6d91bfe402d3c08 /libavformat/xa.c
parente4c01d408a30d9a89ee9a9509f68923b3b715bd9 (diff)
Add more sanity checks for header elements, rejecting files with clearly
invalid values that wouldn't play right anyway and reduce probe score to MAX/2. Passes probetest v2. Originally committed as revision 19842 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/xa.c')
-rw-r--r--libavformat/xa.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libavformat/xa.c b/libavformat/xa.c
index 2f547106ea..fedc2f202e 100644
--- a/libavformat/xa.c
+++ b/libavformat/xa.c
@@ -42,13 +42,24 @@ typedef struct MaxisXADemuxContext {
static int xa_probe(AVProbeData *p)
{
+ int channels, srate, bits_per_sample;
+ if (p->buf_size < 24)
+ return 0;
switch(AV_RL32(p->buf)) {
case XA00_TAG:
case XAI0_TAG:
case XAJ0_TAG:
- return AVPROBE_SCORE_MAX;
+ break;
+ default:
+ return 0;
}
- return 0;
+ channels = AV_RL16(p->buf + 10);
+ srate = AV_RL32(p->buf + 12);
+ bits_per_sample = AV_RL16(p->buf + 22);
+ if (!channels || channels > 8 || !srate || srate > 192000 ||
+ bits_per_sample < 4 || bits_per_sample > 32)
+ return 0;
+ return AVPROBE_SCORE_MAX/2;
}
static int xa_read_header(AVFormatContext *s,