From patchwork Wed Jun 27 18:11:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 9524 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp1152809jad; Wed, 27 Jun 2018 11:12:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfmJSRTCGyI2rGn1olg6GpMcyKDkeNW82ojty0s6yoboRobio2wzHrhZYfWU3lcBtnrb+5r X-Received: by 2002:a1c:3705:: with SMTP id e5-v6mr5655254wma.20.1530123150829; Wed, 27 Jun 2018 11:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530123150; cv=none; d=google.com; s=arc-20160816; b=gnd5MigHVzfgaN/OpjVzPwQ5LJwqz7Ec6igcYRGT9Hp79fjzKN4Q3BY77zwjA+bzOm /oV4G/e4Dw8eHG3rcyadVzE+ImqR8KNJImp1vhAVh3KBKI4iYnIekOj4wrA/e9fm1iCo 2Lnlm6lIj7wEXfozeOSdXOplHBLxJanU60NYgDVfKG8+T3NP1XG1CtAcCzBfiVroDqC3 0VRtZ0grlJQlZJpFh6YqDRyvuZm2RXxrTtMePNpnrcx9VJZzkojpD/kYt5WC3x9qWD/M oRm+aKZAXw+lH1+mcDH1jxXKfGJK0mGAW/gE1h5bI6qCmjdnDRshuzoOS/Ij1bb6BvsV Uglg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=zd7pc/A1s7NP5F5oy5jys/s2YSzLvxd8BkSXVYYMF9U=; b=Pf8irGtZZMw7C0Zpk+1VSFe2DjulA+r1Rc1cUdboxlXFNOcFj2dQMF5MK+kfbva4A0 WoXGJYu+ZxRkgPVeu7uCCo+PQ0A0IjOcj41anBzYEd/neH9dE7zq/ucTYbWyN1KfaNVj GNoKgdobFArDlMo4UoWDyGvaFwVO37RhV3Lsx3KA94VkDpGIs5e2DUhSwn8LsFunovk8 +BxQZEZtuJbDs4VWovcc5OwKJeUUzAC0DC6vy3E9DZSsxKthOCi2XpMa8a2ZjlwyjDxO ovG3zN+93HNTG3/4eWW4I7mdyuipOqitsqjR73mXiH/9B4yZH0vuVXvBr0G+4RZHc/jO G/5g== 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 h2-v6si1280162wrc.223.2018.06.27.11.12.30; Wed, 27 Jun 2018 11:12:30 -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 8A86068A425; Wed, 27 Jun 2018 21:12:19 +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-pe05-1.mx.upcmail.net [84.116.36.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 39108689CD0 for ; Wed, 27 Jun 2018 21:12:13 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fYEvO-0005yR-BC for ffmpeg-devel@ffmpeg.org; Wed, 27 Jun 2018 20:12:14 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 3uC61y00b0S5wYM01uC7pC; Wed, 27 Jun 2018 20:12:07 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 27 Jun 2018 20:11:15 +0200 Message-Id: <20180627181121.30735-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180627181121.30735-1-michael@niedermayer.cc> References: <20180627181121.30735-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/8] avcodec/ac3dec: Check channel_map index 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes: out of array read Fixes: 8924/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EAC3_fuzzer-5851861780267008 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/ac3dec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index b1239a1845..eed8ce5b39 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1671,6 +1671,7 @@ dependent_frame: if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) { uint64_t ich_layout = avpriv_ac3_channel_layout_tab[s->prev_output_mode & ~AC3_OUTPUT_LFEON]; + int channel_map_size = ff_ac3_channels_tab[s->output_mode & ~AC3_OUTPUT_LFEON] + s->lfe_on; uint64_t channel_layout; int extend = 0; @@ -1699,6 +1700,9 @@ dependent_frame: ff_eac3_custom_channel_map_locations[ch][1]); if (index < 0) return AVERROR_INVALIDDATA; + if (extend >= channel_map_size) + return AVERROR_INVALIDDATA; + extended_channel_map[index] = offset + channel_map[extend++]; } else { int i; @@ -1709,6 +1713,9 @@ dependent_frame: 1LL << i); if (index < 0) return AVERROR_INVALIDDATA; + if (extend >= channel_map_size) + return AVERROR_INVALIDDATA; + extended_channel_map[index] = offset + channel_map[extend++]; } }