Bug 1267637: [opus] P3. Reject audio data with unsupported audio configuration. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 27 Apr 2016 17:41:06 +1000
changeset 356821 5cdc7a3eb26eb2c498d6e3da4da74ba817c37cca
parent 356820 bc2d723ca67847f79dd33f64db849f42ab61b158
child 356822 fcd5d2ca6c1ccceaf6d85612692e312b4fff1e01
child 356828 ae5b4e9bd42a73640da394f8c896d2a9250c976b
child 356834 b5b02ef1303eb95da953e10c38183290c04f9ffa
push id16610
push userbmo:jyavenard@mozilla.com
push dateWed, 27 Apr 2016 08:08:26 +0000
reviewersgerald
bugs1267637
milestone49.0a1
Bug 1267637: [opus] P3. Reject audio data with unsupported audio configuration. r?gerald MozReview-Commit-ID: 5od4WqRAorK
dom/media/platforms/agnostic/OpusDecoder.cpp
--- a/dom/media/platforms/agnostic/OpusDecoder.cpp
+++ b/dom/media/platforms/agnostic/OpusDecoder.cpp
@@ -98,20 +98,20 @@ OpusDataDecoder::DecodeHeader(const unsi
   MOZ_ASSERT(!mDecodedHeader);
   mDecodedHeader = true;
 
   mOpusParser = new OpusParser;
   if (!mOpusParser->DecodeHeader(const_cast<unsigned char*>(aData), aLength)) {
     return NS_ERROR_FAILURE;
   }
   int channels = mOpusParser->mChannels;
-  // No channel mapping for more than 8 channels.
-  if (channels > 8) {
-    OPUS_DEBUG("No channel mapping for more than 8 channels. Source is %d channels",
-               channels);
+
+  AudioConfig::ChannelLayout layout(channels);
+  if (!layout.IsValid()) {
+    OPUS_DEBUG("Invalid channel mapping. Source is %d channels", channels);
     return NS_ERROR_FAILURE;
   }
 
   AudioConfig::ChannelLayout vorbisLayout(
     channels, VorbisDataDecoder::VorbisLayout(channels));
   AudioConfig::ChannelLayout smpteLayout(channels);
   static_assert(sizeof(mOpusParser->mMappingTable) / sizeof(mOpusParser->mMappingTable[0]) >= MAX_AUDIO_CHANNELS,
                        "Invalid size set");