X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fwavdec.c;h=410c2ec1f9be093c37461761b827a3e3ede07d3f;hb=6f764d291121f4980b292cdaa537aa8fb10cb93b;hp=8a7f84b17c594b62416ab91bbab42da40993e566;hpb=1137ccef706650138e8f449deb5724e13da7236b;p=ffmpeg diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 8a7f84b17c5..410c2ec1f9b 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -248,7 +248,8 @@ static int wav_read_header(AVFormatContext *s) { int64_t size, av_uninit(data_size); int64_t sample_count = 0; - int rf64; + int rf64 = 0; + char start_code[32]; uint32_t tag; AVIOContext *pb = s->pb; AVStream *st = NULL; @@ -260,17 +261,31 @@ static int wav_read_header(AVFormatContext *s) wav->smv_data_ofs = -1; - /* check RIFF header */ + /* read chunk ID */ tag = avio_rl32(pb); - - rf64 = tag == MKTAG('R', 'F', '6', '4'); - wav->rifx = tag == MKTAG('R', 'I', 'F', 'X'); - if (!rf64 && !wav->rifx && tag != MKTAG('R', 'I', 'F', 'F')) + switch (tag) { + case MKTAG('R', 'I', 'F', 'F'): + break; + case MKTAG('R', 'I', 'F', 'X'): + wav->rifx = 1; + break; + case MKTAG('R', 'F', '6', '4'): + rf64 = 1; + break; + default: + av_get_codec_tag_string(start_code, sizeof(start_code), tag); + av_log(s, AV_LOG_ERROR, "invalid start code %s in RIFF header\n", start_code); return AVERROR_INVALIDDATA; - avio_rl32(pb); /* file size */ - tag = avio_rl32(pb); - if (tag != MKTAG('W', 'A', 'V', 'E')) + } + + /* read chunk size */ + avio_rl32(pb); + + /* read format */ + if (avio_rl32(pb) != MKTAG('W', 'A', 'V', 'E')) { + av_log(s, AV_LOG_ERROR, "invalid format in RIFF header\n"); return AVERROR_INVALIDDATA; + } if (rf64) { if (avio_rl32(pb) != MKTAG('d', 's', '6', '4'))