diff options
Diffstat (limited to 'ffmpeg/libavformat/mpc8.c')
| -rw-r--r-- | ffmpeg/libavformat/mpc8.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/ffmpeg/libavformat/mpc8.c b/ffmpeg/libavformat/mpc8.c index 73f8057..b32bc9c 100644 --- a/ffmpeg/libavformat/mpc8.c +++ b/ffmpeg/libavformat/mpc8.c @@ -92,7 +92,7 @@ static int mpc8_probe(AVProbeData *p) if (size < 2) return 0; if (bs + size - 2 >= bs_end) - return AVPROBE_SCORE_MAX / 4 - 1; //seems to be valid MPC but no header yet + return AVPROBE_SCORE_EXTENSION - 1; // seems to be valid MPC but no header yet if (header_found) { if (size < 11 || size > 28) return 0; @@ -136,11 +136,11 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off) int tag; int64_t size, pos, ppos[2]; uint8_t *buf; - int i, t, seekd; + int i, t, seekd, ret; GetBitContext gb; - if (s->nb_streams<=0) { - av_log(s, AV_LOG_ERROR, "cannot parse stream table before stream header\n"); + if (s->nb_streams == 0) { + av_log(s, AV_LOG_ERROR, "No stream added before parsing seek table\n"); return; } @@ -151,12 +151,19 @@ static void mpc8_parse_seektable(AVFormatContext *s, int64_t off) return; } if (size > INT_MAX/10 || size<=0) { - av_log(s, AV_LOG_ERROR, "Seek table size is invalid\n"); + av_log(s, AV_LOG_ERROR, "Bad seek table size\n"); return; } if(!(buf = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE))) return; - avio_read(s->pb, buf, size); + ret = avio_read(s->pb, buf, size); + if (ret != size) { + av_log(s, AV_LOG_ERROR, "seek table truncated\n"); + av_free(buf); + return; + } + memset(buf+size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + init_get_bits(&gb, buf, size * 8); size = gb_get_v(&gb); if(size > UINT_MAX/4 || size > c->samples/1152){ @@ -241,9 +248,8 @@ static int mpc8_read_header(AVFormatContext *s) st->codec->codec_id = AV_CODEC_ID_MUSEPACK8; st->codec->bits_per_coded_sample = 16; - st->codec->extradata_size = 2; - st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - avio_read(pb, st->codec->extradata, st->codec->extradata_size); + if (ff_get_extradata(st->codec, pb, 2) < 0) + return AVERROR(ENOMEM); st->codec->channels = (st->codec->extradata[1] >> 4) + 1; st->codec->sample_rate = mpc8_rate[st->codec->extradata[0] >> 5]; |
