Mercurial > libavformat.hg
comparison xa.c @ 5180:a026efc0ca86 libavformat
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.
author | reimar |
---|---|
date | Mon, 14 Sep 2009 19:58:51 +0000 |
parents | 49c1d3b27727 |
children | dec5ac461e93 |
comparison
equal
deleted
inserted
replaced
5179:cd0985411145 | 5180:a026efc0ca86 |
---|---|
40 uint32_t audio_frame_counter; | 40 uint32_t audio_frame_counter; |
41 } MaxisXADemuxContext; | 41 } MaxisXADemuxContext; |
42 | 42 |
43 static int xa_probe(AVProbeData *p) | 43 static int xa_probe(AVProbeData *p) |
44 { | 44 { |
45 int channels, srate, bits_per_sample; | |
46 if (p->buf_size < 24) | |
47 return 0; | |
45 switch(AV_RL32(p->buf)) { | 48 switch(AV_RL32(p->buf)) { |
46 case XA00_TAG: | 49 case XA00_TAG: |
47 case XAI0_TAG: | 50 case XAI0_TAG: |
48 case XAJ0_TAG: | 51 case XAJ0_TAG: |
49 return AVPROBE_SCORE_MAX; | 52 break; |
53 default: | |
54 return 0; | |
50 } | 55 } |
51 return 0; | 56 channels = AV_RL16(p->buf + 10); |
57 srate = AV_RL32(p->buf + 12); | |
58 bits_per_sample = AV_RL16(p->buf + 22); | |
59 if (!channels || channels > 8 || !srate || srate > 192000 || | |
60 bits_per_sample < 4 || bits_per_sample > 32) | |
61 return 0; | |
62 return AVPROBE_SCORE_MAX/2; | |
52 } | 63 } |
53 | 64 |
54 static int xa_read_header(AVFormatContext *s, | 65 static int xa_read_header(AVFormatContext *s, |
55 AVFormatParameters *ap) | 66 AVFormatParameters *ap) |
56 { | 67 { |