From patchwork Tue Aug 29 23:20:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 4881 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp3609732jao; Tue, 29 Aug 2017 16:20:48 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4Xf1IYB3rxjFDzj9FmJjqXgNGxct3pYJRakHIj1bH0uGIcdKKnGw399opPG0wCTIKaIjwE X-Received: by 10.28.55.16 with SMTP id e16mr105417wma.142.1504048848018; Tue, 29 Aug 2017 16:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504048847; cv=none; d=google.com; s=arc-20160816; b=mhaY62i1QwWRmHZVhIgsTa+bIudke8u6FGVfncBGuSAXkFtgYhuZGrr4TX/mJrfAVO acoOV/JT3jk/WJ4i4/OJy2jdzj7jgFZ1ElHhNelntLPoo9iQRFY/9jLMCr6T3KqYqEDj G+8pRIQZ+qdvQXuTJoXvmtSpldkkyD5831GxDPYjBJjMptshy4oZS1r/Y7HCJBrpXx0j ncEO5qM7TLclCBRQVS+yqY6kquuOshNDcMA3UeFpmXP9rie/KJIjVRPC8VevdmpHC8gY vCdYdNuCR3iraFX4fucxkRDZZtW+Q6lTCCByMMHXQi44wK3HprQX1yLfUefKg2RqHa2U b2Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to:arc-authentication-results; bh=2KYPCJIcRxasHwEMWZaxC8Wm/bR5Fj3bPGNKhxjaKpM=; b=pgn/qoNHqCLPTxp3wsleFUUZk7Q2MqQ3qqe62UWZcIpiPv+FULV+8TjflyTwvRrajw 55cAqwkCBUcVVQd1Z112K+cViQneLoFc50J/EdBYFeNX7yOLFITrWViz/vOG26E2a/4w j4TVBVHgIhx6Hs4OiiOAaPXrecG5hZJVgcc9bc4Ksen0omn9xEnucyOY0yIdcXsOs3+u J1P6BD6N45Q57x02Dqi2ozb7gQ9EagIssKKk7zAbv7oRqNdWirCP/dexSw3a6DsjrxVI DOd7OAoIkDUEO5s8aacfKVnmdPAyqgQMj4ssj311qSUllzsYO23PEE/XM26FtAFuIdjM s3hQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p17si504285wmg.107.2017.08.29.16.20.46; Tue, 29 Aug 2017 16:20:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 04EB868A207; Wed, 30 Aug 2017 02:20:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-1.mx.upcmail.net (vie01a-dmta-pe08-1.mx.upcmail.net [84.116.36.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E8D9B68A1B0 for ; Wed, 30 Aug 2017 02:20:36 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe08.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dmpoC-0000oS-LE for ffmpeg-devel@ffmpeg.org; Wed, 30 Aug 2017 01:20:36 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 3BLV1w01A0S5wYM01BLWcJ; Wed, 30 Aug 2017 01:20:30 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 30 Aug 2017 01:20:26 +0200 Message-Id: <20170829232027.32431-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170829232027.32431-1-michael@niedermayer.cc> References: <20170829232027.32431-1-michael@niedermayer.cc> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avformat/mxfdec: Fix DoS issues in mxf_read_index_entry_array() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: =?UTF-8?q?=E5=AD=99=E6=B5=A9=28=E6=99=93=E9=BB=91=29?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: 孙浩(晓黑) Fixes: 20170829A.mxf Co-Author: 张洪亮(望初)" Found-by: Xiaohei and Wangchu from Alibaba Security Team Signed-off-by: Michael Niedermayer --- libavformat/mxfdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index f8d0f9e057..6adb77d81f 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -899,6 +899,8 @@ static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg segment->nb_index_entries = avio_rb32(pb); length = avio_rb32(pb); + if(segment->nb_index_entries && length < 11) + return AVERROR_INVALIDDATA; if (!(segment->temporal_offset_entries=av_calloc(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) || !(segment->flag_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->flag_entries))) || @@ -909,6 +911,8 @@ static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg } for (i = 0; i < segment->nb_index_entries; i++) { + if(avio_feof(pb)) + return AVERROR_INVALIDDATA; segment->temporal_offset_entries[i] = avio_r8(pb); avio_r8(pb); /* KeyFrameOffset */ segment->flag_entries[i] = avio_r8(pb);