avformat/utils: Fix potential integer overflow in extract_extradata()
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 26 Sep 2018 22:00:26 +0000 (00:00 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 7 Oct 2018 01:03:09 +0000 (03:03 +0200)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/utils.c

index dcc0de9..a8ac902 100644 (file)
@@ -3544,7 +3544,9 @@ static int extract_extradata(AVStream *st, AVPacket *pkt)
                                             &extradata_size);
 
         if (extradata) {
-            sti->avctx->extradata = av_mallocz(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+            av_assert0(!sti->avctx->extradata);
+            if ((unsigned)extradata_size < FF_MAX_EXTRADATA_SIZE)
+                sti->avctx->extradata = av_mallocz(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
             if (!sti->avctx->extradata) {
                 av_packet_unref(pkt_ref);
                 return AVERROR(ENOMEM);