avformat/wavdec: Dont trust the fact chunk for PCM
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 9 Oct 2013 19:43:06 +0000 (21:43 +0200)
committerCarl Eugen Hoyos <cehoyos@ag.or.at>
Thu, 24 Oct 2013 09:35:11 +0000 (11:35 +0200)
Fixes Ticket3033

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 83fc6c822b06688e572333299927d93eb3c6c426)

Conflicts:
libavformat/wav.c

libavformat/wav.c

index ec527b8..4648486 100644 (file)
@@ -546,8 +546,15 @@ break_loop:
 
     avio_seek(pb, data_ofs, SEEK_SET);
 
-    if (!sample_count && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id))
-        sample_count = (data_size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
+    if (!sample_count || av_get_exact_bits_per_sample(st->codec->codec_id) > 0)
+        if (   st->codec->channels
+            && data_size
+            && av_get_bits_per_sample(st->codec->codec_id)
+            && wav->data_end <= avio_size(pb))
+            sample_count = (data_size << 3)
+                                  /
+                (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
+
     if (sample_count)
         st->duration = sample_count;