riffdec: prevent negative bit rate
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Fri, 10 Jul 2015 22:09:46 +0000 (00:09 +0200)
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Thu, 26 Nov 2015 00:37:33 +0000 (01:37 +0100)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 189420cb561929e05f5cc4224cdca83740a24a32)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
libavformat/riffdec.c

index 4afe807..632c58c 100644 (file)
@@ -103,6 +103,14 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
         codec->bit_rate    = avio_rb32(pb) * 8;
         codec->block_align = avio_rb16(pb);
     }
+    if (codec->bit_rate < 0) {
+        av_log(s, AV_LOG_WARNING,
+               "Invalid bit rate: %d\n", codec->bit_rate);
+        if (s->error_recognition & AV_EF_EXPLODE)
+            return AVERROR_INVALIDDATA;
+        else
+            codec->bit_rate = 0;
+    }
     if (size == 14) {  /* We're dealing with plain vanilla WAVEFORMAT */
         codec->bits_per_coded_sample = 8;
     } else {