Mercurial > libavformat.hg
comparison c93.c @ 5181:c900e8690782 libavformat
Check the index validity more thoroughly for the c93 probe function.
In particular, check that length of the first index entries is not 0 since
that is interpreted "end of file" and makes no sense in the very first entries.
author | reimar |
---|---|
date | Mon, 14 Sep 2009 20:01:32 +0000 |
parents | 3d6e7901bf05 |
children | 536e5527c1e0 |
comparison
equal
deleted
inserted
replaced
5180:a026efc0ca86 | 5181:c900e8690782 |
---|---|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 */ | 20 */ |
21 | 21 |
22 #include "avformat.h" | 22 #include "avformat.h" |
23 #include "voc.h" | 23 #include "voc.h" |
24 #include "libavutil/intreadwrite.h" | |
24 | 25 |
25 typedef struct { | 26 typedef struct { |
26 uint16_t index; | 27 uint16_t index; |
27 uint8_t length; | 28 uint8_t length; |
28 uint8_t frames; | 29 uint8_t frames; |
41 AVStream *audio; | 42 AVStream *audio; |
42 } C93DemuxContext; | 43 } C93DemuxContext; |
43 | 44 |
44 static int probe(AVProbeData *p) | 45 static int probe(AVProbeData *p) |
45 { | 46 { |
46 if (p->buf[0] == 0x01 && p->buf[1] == 0x00 && | 47 int i; |
47 p->buf[4] == 0x01 + p->buf[2] && | 48 int index = 1; |
48 p->buf[8] == p->buf[4] + p->buf[6] && | 49 if (p->buf_size < 16) |
49 p->buf[12] == p->buf[8] + p->buf[10]) | 50 return 0; |
50 return AVPROBE_SCORE_MAX; | 51 for (i = 0; i < 16; i += 4) { |
51 | 52 if (AV_RL16(p->buf + i) != index || !p->buf[i + 2] || !p->buf[i + 3]) |
52 return 0; | 53 return 0; |
54 index += p->buf[i + 2]; | |
55 } | |
56 return AVPROBE_SCORE_MAX; | |
53 } | 57 } |
54 | 58 |
55 static int read_header(AVFormatContext *s, | 59 static int read_header(AVFormatContext *s, |
56 AVFormatParameters *ap) | 60 AVFormatParameters *ap) |
57 { | 61 { |