Mercurial > libavformat.hg
changeset 2001:1a3c9056982a libavformat
allocate 32 extra bytes at the end of the probe buffer and remove most probe buf_size checks
author | michael |
---|---|
date | Sun, 08 Apr 2007 11:34:15 +0000 |
parents | ce51095f383b |
children | 1aa1bc9c5be8 |
files | 4xm.c aiff.c amr.c apc.c asf.c au.c avformat.h avidec.c avs.c bethsoftvid.c c93.c dsicin.c dxa.c electronicarts.c ffm.c flic.c flvdec.c gxf.c idcin.c idroq.c ipmovie.c libnut.c matroska.c mm.c mmf.c mov.c mp3.c mpc.c mpeg.c mtv.c nsvdec.c nuv.c ogg2.c raw.c rm.c segafilm.c sierravmd.c smacker.c sol.c swf.c thp.c tta.c utils.c vocdec.c yuv4mpeg.c |
diffstat | 45 files changed, 7 insertions(+), 104 deletions(-) [+] |
line wrap: on
line diff
--- a/4xm.c Sun Apr 08 09:50:08 2007 +0000 +++ b/4xm.c Sun Apr 08 11:34:15 2007 +0000 @@ -79,9 +79,6 @@ static int fourxm_probe(AVProbeData *p) { - if (p->buf_size < 12) - return 0; - if ((AV_RL32(&p->buf[0]) != RIFF_TAG) || (AV_RL32(&p->buf[8]) != _4XMV_TAG)) return 0;
--- a/aiff.c Sun Apr 08 09:50:08 2007 +0000 +++ b/aiff.c Sun Apr 08 11:34:15 2007 +0000 @@ -275,8 +275,6 @@ static int aiff_probe(AVProbeData *p) { /* check file header */ - if (p->buf_size < 16) - return 0; if (p->buf[0] == 'F' && p->buf[1] == 'O' && p->buf[2] == 'R' && p->buf[3] == 'M' && p->buf[8] == 'A' && p->buf[9] == 'I' &&
--- a/amr.c Sun Apr 08 09:50:08 2007 +0000 +++ b/amr.c Sun Apr 08 11:34:15 2007 +0000 @@ -73,8 +73,6 @@ //This will also trigger multichannel files: "#!AMR_MC1.0\n" and //"#!AMR-WB_MC1.0\n" (not supported) - if (p->buf_size < 5) - return 0; if(memcmp(p->buf,AMR_header,5)==0) return AVPROBE_SCORE_MAX; else
--- a/apc.c Sun Apr 08 09:50:08 2007 +0000 +++ b/apc.c Sun Apr 08 11:34:15 2007 +0000 @@ -24,9 +24,6 @@ static int apc_probe(AVProbeData *p) { - if (p->buf_size < 8) - return 0; - if (!strncmp(p->buf, "CRYO_APC", 8)) return AVPROBE_SCORE_MAX;
--- a/asf.c Sun Apr 08 09:50:08 2007 +0000 +++ b/asf.c Sun Apr 08 11:34:15 2007 +0000 @@ -119,9 +119,6 @@ static int asf_probe(AVProbeData *pd) { /* check file header */ - if (pd->buf_size <= 32) - return 0; - if (!memcmp(pd->buf, &asf_header, sizeof(GUID))) return AVPROBE_SCORE_MAX; else
--- a/au.c Sun Apr 08 09:50:08 2007 +0000 +++ b/au.c Sun Apr 08 11:34:15 2007 +0000 @@ -103,8 +103,6 @@ static int au_probe(AVProbeData *p) { /* check file header */ - if (p->buf_size <= 24) - return 0; if (p->buf[0] == '.' && p->buf[1] == 's' && p->buf[2] == 'n' && p->buf[3] == 'd') return AVPROBE_SCORE_MAX;
--- a/avformat.h Sun Apr 08 09:50:08 2007 +0000 +++ b/avformat.h Sun Apr 08 11:34:15 2007 +0000 @@ -25,8 +25,8 @@ extern "C" { #endif -#define LIBAVFORMAT_VERSION_INT ((51<<16)+(11<<8)+0) -#define LIBAVFORMAT_VERSION 51.11.0 +#define LIBAVFORMAT_VERSION_INT ((51<<16)+(12<<8)+0) +#define LIBAVFORMAT_VERSION 51.12.0 #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) @@ -132,6 +132,7 @@ } AVProbeData; #define AVPROBE_SCORE_MAX 100 ///< max score, half of that is used for file extension based detection +#define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer typedef struct AVFormatParameters { AVRational time_base;
--- a/avidec.c Sun Apr 08 09:50:08 2007 +0000 +++ b/avidec.c Sun Apr 08 11:34:15 2007 +0000 @@ -995,8 +995,6 @@ static int avi_probe(AVProbeData *p) { /* check file header */ - if (p->buf_size <= 32) - return 0; if (p->buf[0] == 'R' && p->buf[1] == 'I' && p->buf[2] == 'F' && p->buf[3] == 'F' && p->buf[8] == 'A' && p->buf[9] == 'V' &&
--- a/avs.c Sun Apr 08 09:50:08 2007 +0000 +++ b/avs.c Sun Apr 08 11:34:15 2007 +0000 @@ -47,8 +47,6 @@ { const uint8_t *d; - if (p->buf_size < 2) - return 0; d = p->buf; if (d[0] == 'w' && d[1] == 'W' && d[2] == 0x10 && d[3] == 0) return 50;
--- a/bethsoftvid.c Sun Apr 08 09:50:08 2007 +0000 +++ b/bethsoftvid.c Sun Apr 08 11:34:15 2007 +0000 @@ -49,7 +49,7 @@ static int vid_probe(AVProbeData *p) { // little endian VID tag, file starts with "VID\0" - if (p->buf_size < 4 || AV_RL32(p->buf) != MKTAG('V', 'I', 'D', 0)) + if (AV_RL32(p->buf) != MKTAG('V', 'I', 'D', 0)) return 0; return AVPROBE_SCORE_MAX;
--- a/c93.c Sun Apr 08 09:50:08 2007 +0000 +++ b/c93.c Sun Apr 08 11:34:15 2007 +0000 @@ -44,9 +44,6 @@ static int probe(AVProbeData *p) { - if (p->buf_size < 13) - return 0; - if (p->buf[0] == 0x01 && p->buf[1] == 0x00 && p->buf[4] == 0x01 + p->buf[2] && p->buf[8] == p->buf[4] + p->buf[6] &&
--- a/dsicin.c Sun Apr 08 09:50:08 2007 +0000 +++ b/dsicin.c Sun Apr 08 11:34:15 2007 +0000 @@ -58,9 +58,6 @@ static int cin_probe(AVProbeData *p) { - if (p->buf_size < 18) - return 0; - /* header starts with this special marker */ if (AV_RL32(&p->buf[0]) != 0x55AA0000) return 0;
--- a/dxa.c Sun Apr 08 09:50:08 2007 +0000 +++ b/dxa.c Sun Apr 08 11:34:15 2007 +0000 @@ -36,8 +36,6 @@ static int dxa_probe(AVProbeData *p) { /* check file header */ - if (p->buf_size <= 4) - return 0; if (p->buf[0] == 'D' && p->buf[1] == 'E' && p->buf[2] == 'X' && p->buf[3] == 'A') return AVPROBE_SCORE_MAX;
--- a/electronicarts.c Sun Apr 08 09:50:08 2007 +0000 +++ b/electronicarts.c Sun Apr 08 11:34:15 2007 +0000 @@ -165,9 +165,6 @@ static int ea_probe(AVProbeData *p) { - if (p->buf_size < 4) - return 0; - if (AV_RL32(&p->buf[0]) != SCHl_TAG) return 0;
--- a/ffm.c Sun Apr 08 09:50:08 2007 +0000 +++ b/ffm.c Sun Apr 08 11:34:15 2007 +0000 @@ -758,7 +758,7 @@ static int ffm_probe(AVProbeData *p) { - if (p->buf_size >= 4 && + if ( p->buf[0] == 'F' && p->buf[1] == 'F' && p->buf[2] == 'M' && p->buf[3] == '1') return AVPROBE_SCORE_MAX + 1;
--- a/flic.c Sun Apr 08 09:50:08 2007 +0000 +++ b/flic.c Sun Apr 08 11:34:15 2007 +0000 @@ -55,9 +55,6 @@ { int magic_number; - if (p->buf_size < 6) - return 0; - magic_number = AV_RL16(&p->buf[4]); if ((magic_number != FLIC_FILE_MAGIC_1) && (magic_number != FLIC_FILE_MAGIC_2) &&
--- a/flvdec.c Sun Apr 08 09:50:08 2007 +0000 +++ b/flvdec.c Sun Apr 08 11:34:15 2007 +0000 @@ -31,8 +31,6 @@ { const uint8_t *d; - if (p->buf_size < 6) - return 0; d = p->buf; if (d[0] == 'F' && d[1] == 'L' && d[2] == 'V' && d[3] < 5 && d[5]==0) { return AVPROBE_SCORE_MAX;
--- a/gxf.c Sun Apr 08 09:50:08 2007 +0000 +++ b/gxf.c Sun Apr 08 11:34:15 2007 +0000 @@ -87,8 +87,6 @@ static int gxf_probe(AVProbeData *p) { static const uint8_t startcode[] = {0, 0, 0, 0, 1, 0xbc}; // start with map packet static const uint8_t endcode[] = {0, 0, 0, 0, 0xe1, 0xe2}; - if (p->buf_size < 16) - return 0; if (!memcmp(p->buf, startcode, sizeof(startcode)) && !memcmp(&p->buf[16 - sizeof(endcode)], endcode, sizeof(endcode))) return AVPROBE_SCORE_MAX;
--- a/idcin.c Sun Apr 08 09:50:08 2007 +0000 +++ b/idcin.c Sun Apr 08 11:34:15 2007 +0000 @@ -104,10 +104,6 @@ * audio channels: 0 for no audio, or 1 or 2 */ - /* cannot proceed without 20 bytes */ - if (p->buf_size < 20) - return 0; - /* check the video width */ number = AV_RL32(&p->buf[0]); if ((number == 0) || (number > 1024))
--- a/idroq.c Sun Apr 08 09:50:08 2007 +0000 +++ b/idroq.c Sun Apr 08 11:34:15 2007 +0000 @@ -58,9 +58,6 @@ static int roq_probe(AVProbeData *p) { - if (p->buf_size < 6) - return 0; - if ((AV_RL16(&p->buf[0]) != RoQ_MAGIC_NUMBER) || (AV_RL32(&p->buf[2]) != 0xFFFFFFFF)) return 0;
--- a/ipmovie.c Sun Apr 08 09:50:08 2007 +0000 +++ b/ipmovie.c Sun Apr 08 11:34:15 2007 +0000 @@ -507,8 +507,6 @@ static int ipmovie_probe(AVProbeData *p) { - if (p->buf_size < IPMOVIE_SIGNATURE_SIZE) - return 0; if (strncmp(p->buf, IPMOVIE_SIGNATURE, IPMOVIE_SIGNATURE_SIZE) != 0) return 0;
--- a/libnut.c Sun Apr 08 09:50:08 2007 +0000 +++ b/libnut.c Sun Apr 08 11:34:15 2007 +0000 @@ -166,7 +166,7 @@ #endif //CONFIG_MUXERS static int nut_probe(AVProbeData *p) { - if (p->buf_size >= ID_LENGTH && !memcmp(p->buf, ID_STRING, ID_LENGTH)) return AVPROBE_SCORE_MAX; + if (!memcmp(p->buf, ID_STRING, ID_LENGTH)) return AVPROBE_SCORE_MAX; return 0; }
--- a/matroska.c Sun Apr 08 09:50:08 2007 +0000 +++ b/matroska.c Sun Apr 08 11:34:15 2007 +0000 @@ -1074,9 +1074,6 @@ int len_mask = 0x80, size = 1, n = 1; uint8_t probe_data[] = { 'm', 'a', 't', 'r', 'o', 's', 'k', 'a' }; - if (p->buf_size < 5) - return 0; - /* ebml header? */ if ((p->buf[0] << 24 | p->buf[1] << 16 | p->buf[2] << 8 | p->buf[3]) != EBML_ID_HEADER)
--- a/mm.c Sun Apr 08 09:50:08 2007 +0000 +++ b/mm.c Sun Apr 08 11:34:15 2007 +0000 @@ -59,8 +59,6 @@ static int mm_probe(AVProbeData *p) { /* the first chunk is always the header */ - if (p->buf_size < MM_PREAMBLE_SIZE) - return 0; 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)
--- a/mmf.c Sun Apr 08 09:50:08 2007 +0000 +++ b/mmf.c Sun Apr 08 11:34:15 2007 +0000 @@ -168,8 +168,6 @@ static int mmf_probe(AVProbeData *p) { /* check file header */ - if (p->buf_size <= 32) - return 0; if (p->buf[0] == 'M' && p->buf[1] == 'M' && p->buf[2] == 'M' && p->buf[3] == 'D' && p->buf[8] == 'C' && p->buf[9] == 'N' &&
--- a/mov.c Sun Apr 08 09:50:08 2007 +0000 +++ b/mov.c Sun Apr 08 11:34:15 2007 +0000 @@ -1320,8 +1320,6 @@ int score = 0; /* check file header */ - if (p->buf_size <= 12) - return 0; offset = 0; for(;;) { /* ignore invalid offset */
--- a/mp3.c Sun Apr 08 09:50:08 2007 +0000 +++ b/mp3.c Sun Apr 08 11:34:15 2007 +0000 @@ -252,9 +252,6 @@ uint8_t *buf, *buf2, *end; AVCodecContext avctx; - if(p->buf_size < ID3_HEADER_SIZE) - return 0; - if(id3_match(p->buf)) return AVPROBE_SCORE_MAX/2+1; // this must be less then mpeg-ps because some retards put id3 tage before mpeg-ps files
--- a/mpc.c Sun Apr 08 09:50:08 2007 +0000 +++ b/mpc.c Sun Apr 08 11:34:15 2007 +0000 @@ -42,8 +42,6 @@ static int mpc_probe(AVProbeData *p) { const uint8_t *d = p->buf; - if (p->buf_size < 32) - return 0; if (d[0] == 'M' && d[1] == 'P' && d[2] == '+' && (d[3] == 0x17 || d[3] == 0x7)) return AVPROBE_SCORE_MAX; if (d[0] == 'I' && d[1] == 'D' && d[2] == '3')
--- a/mpeg.c Sun Apr 08 09:50:08 2007 +0000 +++ b/mpeg.c Sun Apr 08 11:34:15 2007 +0000 @@ -1260,8 +1260,6 @@ static int cdxa_probe(AVProbeData *p) { /* check file header */ - if (p->buf_size <= 32) - return 0; if (p->buf[0] == 'R' && p->buf[1] == 'I' && p->buf[2] == 'F' && p->buf[3] == 'F' && p->buf[8] == 'C' && p->buf[9] == 'D' &&
--- a/mtv.c Sun Apr 08 09:50:08 2007 +0000 +++ b/mtv.c Sun Apr 08 11:34:15 2007 +0000 @@ -54,9 +54,6 @@ static int mtv_probe(AVProbeData *p) { - if(p->buf_size < 3) - return 0; - /* Magic is 'AMV' */ if(*(p->buf) != 'A' || *(p->buf+1) != 'M' || *(p->buf+2) != 'V')
--- a/nsvdec.c Sun Apr 08 09:50:08 2007 +0000 +++ b/nsvdec.c Sun Apr 08 11:34:15 2007 +0000 @@ -728,8 +728,6 @@ int i; // PRINT(("nsv_probe(), buf_size %d\n", p->buf_size)); /* check file header */ - if (p->buf_size <= 32) - return 0; if (p->buf[0] == 'N' && p->buf[1] == 'S' && p->buf[2] == 'V' && p->buf[3] == 'f') return AVPROBE_SCORE_MAX;
--- a/nuv.c Sun Apr 08 09:50:08 2007 +0000 +++ b/nuv.c Sun Apr 08 11:34:15 2007 +0000 @@ -35,8 +35,6 @@ } frametype_t; static int nuv_probe(AVProbeData *p) { - if (p->buf_size < 12) - return 0; if (!memcmp(p->buf, "NuppelVideo", 12)) return AVPROBE_SCORE_MAX; if (!memcmp(p->buf, "MythTVVideo", 12))
--- a/ogg2.c Sun Apr 08 09:50:08 2007 +0000 +++ b/ogg2.c Sun Apr 08 11:34:15 2007 +0000 @@ -676,8 +676,6 @@ static int ogg_probe(AVProbeData *p) { - if (p->buf_size < 6) - return 0; if (p->buf[0] == 'O' && p->buf[1] == 'g' && p->buf[2] == 'g' && p->buf[3] == 'S' && p->buf[4] == 0x0 && p->buf[5] <= 0x7 )
--- a/raw.c Sun Apr 08 09:50:08 2007 +0000 +++ b/raw.c Sun Apr 08 11:34:15 2007 +0000 @@ -382,8 +382,6 @@ int code; const uint8_t *d; - if (p->buf_size < 6) - return 0; d = p->buf; code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2); if (code == 0x20) { @@ -397,8 +395,6 @@ int code; const uint8_t *d; - if (p->buf_size < 6) - return 0; d = p->buf; code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4); if (code == 0x10) {
--- a/rm.c Sun Apr 08 09:50:08 2007 +0000 +++ b/rm.c Sun Apr 08 11:34:15 2007 +0000 @@ -1063,8 +1063,6 @@ static int rm_probe(AVProbeData *p) { /* check file header */ - if (p->buf_size <= 32) - return 0; if ((p->buf[0] == '.' && p->buf[1] == 'R' && p->buf[2] == 'M' && p->buf[3] == 'F' && p->buf[4] == 0 && p->buf[5] == 0) ||
--- a/segafilm.c Sun Apr 08 09:50:08 2007 +0000 +++ b/segafilm.c Sun Apr 08 11:34:15 2007 +0000 @@ -66,9 +66,6 @@ static int film_probe(AVProbeData *p) { - if (p->buf_size < 4) - return 0; - if (AV_RB32(&p->buf[0]) != FILM_TAG) return 0;
--- a/sierravmd.c Sun Apr 08 09:50:08 2007 +0000 +++ b/sierravmd.c Sun Apr 08 11:34:15 2007 +0000 @@ -59,9 +59,6 @@ static int vmd_probe(AVProbeData *p) { - if (p->buf_size < 2) - return 0; - /* check if the first 2 bytes of the file contain the appropriate size * of a VMD header chunk */ if (AV_RL16(&p->buf[0]) != VMD_HEADER_SIZE - 2)
--- a/smacker.c Sun Apr 08 09:50:08 2007 +0000 +++ b/smacker.c Sun Apr 08 11:34:15 2007 +0000 @@ -88,8 +88,6 @@ static int smacker_probe(AVProbeData *p) { - if (p->buf_size < 4) - return 0; if(p->buf[0] == 'S' && p->buf[1] == 'M' && p->buf[2] == 'K' && (p->buf[3] == '2' || p->buf[3] == '4')) return AVPROBE_SCORE_MAX;
--- a/sol.c Sun Apr 08 09:50:08 2007 +0000 +++ b/sol.c Sun Apr 08 11:34:15 2007 +0000 @@ -35,8 +35,6 @@ { /* check file header */ uint16_t magic; - if (p->buf_size <= 14) - return 0; magic=le2me_16(*((uint16_t*)p->buf)); if ((magic == 0x0B8D || magic == 0x0C0D || magic == 0x0C8D) && p->buf[2] == 'S' && p->buf[3] == 'O' &&
--- a/swf.c Sun Apr 08 09:50:08 2007 +0000 +++ b/swf.c Sun Apr 08 11:34:15 2007 +0000 @@ -618,8 +618,6 @@ static int swf_probe(AVProbeData *p) { /* check file header */ - if (p->buf_size <= 16) - return 0; if ((p->buf[0] == 'F' || p->buf[0] == 'C') && p->buf[1] == 'W' && p->buf[2] == 'S') return AVPROBE_SCORE_MAX;
--- a/thp.c Sun Apr 08 09:50:08 2007 +0000 +++ b/thp.c Sun Apr 08 11:34:15 2007 +0000 @@ -47,9 +47,6 @@ static int thp_probe(AVProbeData *p) { /* check file header */ - if (p->buf_size < 4) - return 0; - if (AV_RL32(p->buf) == MKTAG('T', 'H', 'P', '\0')) return AVPROBE_SCORE_MAX; else
--- a/tta.c Sun Apr 08 09:50:08 2007 +0000 +++ b/tta.c Sun Apr 08 11:34:15 2007 +0000 @@ -29,8 +29,6 @@ static int tta_probe(AVProbeData *p) { const uint8_t *d = p->buf; - if (p->buf_size < 4) - return 0; if (d[0] == 'T' && d[1] == 'T' && d[2] == 'A' && d[3] == '1') return 80; return 0;
--- a/utils.c Sun Apr 08 09:50:08 2007 +0000 +++ b/utils.c Sun Apr 08 11:34:15 2007 +0000 @@ -429,7 +429,7 @@ for(probe_size= PROBE_BUF_MIN; probe_size<=PROBE_BUF_MAX && !fmt; probe_size<<=1){ int score= probe_size < PROBE_BUF_MAX ? AVPROBE_SCORE_MAX/4 : 0; /* read probe data */ - pd->buf= av_realloc(pd->buf, probe_size); + pd->buf= av_realloc(pd->buf, probe_size + AVPROBE_PADDING_SIZE); pd->buf_size = get_buffer(pb, pd->buf, probe_size); if (url_fseek(pb, 0, SEEK_SET) < 0) { url_fclose(pb);
--- a/vocdec.c Sun Apr 08 09:50:08 2007 +0000 +++ b/vocdec.c Sun Apr 08 11:34:15 2007 +0000 @@ -28,8 +28,6 @@ { int version, check; - if (p->buf_size < 26) - return 0; if (memcmp(p->buf, voc_magic, sizeof(voc_magic) - 1)) return 0; version = p->buf[22] | (p->buf[23] << 8);
--- a/yuv4mpeg.c Sun Apr 08 09:50:08 2007 +0000 +++ b/yuv4mpeg.c Sun Apr 08 11:34:15 2007 +0000 @@ -386,8 +386,6 @@ static int yuv4_probe(AVProbeData *pd) { /* check file header */ - if (pd->buf_size <= sizeof(Y4M_MAGIC)) - return 0; if (strncmp(pd->buf, Y4M_MAGIC, sizeof(Y4M_MAGIC)-1)==0) return AVPROBE_SCORE_MAX; else