Bug 1366201 - P5. Get around FFmpeg bug with corrupted data. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 25 Oct 2017 18:25:37 +0200
changeset 686271 139967a109c190f9fb25a8448a7b64ce738c7a3c
parent 686270 8f725401fbfb745f7f2b9502ace52be7a552ba3b
child 686793 161e4020743e1cf401bb685c5684fffd7d121297
push id86149
push userbmo:jyavenard@mozilla.com
push dateWed, 25 Oct 2017 17:33:05 +0000
reviewersgerald
bugs1366201
milestone58.0a1
Bug 1366201 - P5. Get around FFmpeg bug with corrupted data. r?gerald According to FFmpeg documentation, the out parameter is "set to size of parsed buffer or zero if not yet finished. " however this is only the case if no error occurred; otherwise it is left untouched. We want the invalid content to generate a decoding error, so we set size to inputSize to ensure decoding failed later. MozReview-Commit-ID: FZeiZUdUtLG
dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -212,18 +212,18 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(
 
 #if LIBAVCODEC_VERSION_MAJOR >= 54
   if (inputSize && mCodecParser && (mCodecID == AV_CODEC_ID_VP8
 #if LIBAVCODEC_VERSION_MAJOR >= 55
       || mCodecID == AV_CODEC_ID_VP9
 #endif
       )) {
     while (inputSize) {
-      uint8_t* data;
-      int size;
+      uint8_t* data = inputData;
+      int size = inputSize;
       int len = mLib->av_parser_parse2(
         mCodecParser, mCodecContext, &data, &size, inputData, inputSize,
         aSample->mTime.ToMicroseconds(), aSample->mTimecode.ToMicroseconds(),
         aSample->mOffset);
       if (size_t(len) > inputSize) {
         return NS_ERROR_DOM_MEDIA_DECODE_ERR;
       }
       inputData += len;