]> git.sesse.net Git - ffmpeg/commitdiff
lavc: check channel count after decoder init
authorJustin Ruggles <justin.ruggles@gmail.com>
Tue, 23 Oct 2012 04:56:00 +0000 (00:56 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Thu, 1 Nov 2012 15:29:13 +0000 (11:29 -0400)
Ensures the decoder did not set channel count to an insanely high value
during initialization, which could cause large memory usage when it tries to
get a buffer during decoding.

libavcodec/utils.c

index b4e7ed6b6bc81f073f71212a0dc5f2eeabd6f072..58dfe971e1be46a2f4331947415d33101032aaf3 100644 (file)
@@ -881,6 +881,11 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
                 avctx->channel_layout = 0;
             }
         }
+        if (avctx->channels && avctx->channels < 0 ||
+            avctx->channels > FF_SANE_NB_CHANNELS) {
+            ret = AVERROR(EINVAL);
+            goto free_and_end;
+        }
     }
 end:
     entangled_thread_counter--;