X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fwavdec.c;h=52194f54efccfd96674b45b65f9ef12c426d9b32;hb=ed58f8475fa8e659abc887fcd4ef1bd886be397d;hp=6a024de683a906834ad6968bac01e1137121ab2e;hpb=409e684e79b6ee0c511292326f09b13fe230e58e;p=ffmpeg diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 6a024de683a..52194f54efc 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -129,7 +129,7 @@ static int64_t find_tag(WAVDemuxContext * wav, AVIOContext *pb, uint32_t tag1) return size; } -static int wav_probe(AVProbeData *p) +static int wav_probe(const AVProbeData *p) { /* check file header */ if (p->buf_size <= 32) @@ -233,9 +233,9 @@ static inline int wav_parse_bext_string(AVFormatContext *s, const char *key, char temp[257]; int ret; - av_assert0(length <= sizeof(temp)); - if ((ret = avio_read(s->pb, temp, length)) < 0) - return ret; + av_assert0(length < sizeof(temp)); + if ((ret = avio_read(s->pb, temp, length)) != length) + return ret < 0 ? ret : AVERROR_INVALIDDATA; temp[length] = 0; @@ -304,8 +304,10 @@ static int wav_parse_bext_tag(AVFormatContext *s, int64_t size) if (!(coding_history = av_malloc(size + 1))) return AVERROR(ENOMEM); - if ((ret = avio_read(s->pb, coding_history, size)) < 0) - return ret; + if ((ret = avio_read(s->pb, coding_history, size)) != size) { + av_free(coding_history); + return ret < 0 ? ret : AVERROR_INVALIDDATA; + } coding_history[size] = 0; if ((ret = av_dict_set(&s->metadata, "coding_history", coding_history, @@ -588,6 +590,8 @@ break_loop: } else if (st->codecpar->codec_id == AV_CODEC_ID_XMA1 || st->codecpar->codec_id == AV_CODEC_ID_XMA2) { st->codecpar->block_align = 2048; + } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st->codecpar->channels > 2) { + st->codecpar->block_align *= st->codecpar->channels; } ff_metadata_conv_ctx(s, NULL, wav_metadata_conv); @@ -774,7 +778,7 @@ AVInputFormat ff_wav_demuxer = { #endif /* CONFIG_WAV_DEMUXER */ #if CONFIG_W64_DEMUXER -static int w64_probe(AVProbeData *p) +static int w64_probe(const AVProbeData *p) { if (p->buf_size <= 40) return 0;