From patchwork Thu May 17 12:38:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 8998 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp4045251jad; Thu, 17 May 2018 05:40:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr8tRV2Z1Raci2zqGxAH8D0Qk3he4ABWcD1Gy4lUozFNT29gdEP//5KM54D/aOrO2wNBSOO X-Received: by 2002:a1c:ee95:: with SMTP id j21-v6mr1712214wmi.16.1526560852475; Thu, 17 May 2018 05:40:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526560852; cv=none; d=google.com; s=arc-20160816; b=VPLgWSX8feJbIbEC3jw4AiAy48GM8jVzck7Q9aFPtyDNbEB+lPYSLocEavZ5OdEtem S9+QT1NMahNDd2Hy2iair3HvNcEbzVPeoTkTBNeXuLYLeyy6ewCvhPooaKFVsTjHLRDh VJmXJRLRDIeqX3dGXUHOK+rMQcx3yND7VaCTTGtdPIBgSLOTGeBqRsCiM9NFg30Aiwfj /yKNKV2vLQGzY9d77saaAibZEHYlu8ZyYNMDFpL+anHdY4I0jkgXfLWBK4M15IWxr92B EE9MV8TvBMWEzUrJvtEsghb2K8id42nkq+hftSCKgtiXetqU366yYA24eqJZo3HiNnvK iIFg== 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=t0ofy0zqE5bKOzoYrsOz92YQFtoiu34l01cMWZFlVVY=; b=ZaS4CZIwqzkdQ5nQxXq2wli99kWo894AmD8p4bxOAb+kowsM+I1OeNUT2Fl/an36tZ r52q+m3Nrqe/4L+3f1lwRiDLLZl4rwYYKwEkpbgg2DugIkGTLzusL0T2YHuMHERb35nc WR4OIbF/hgrNLrKb9NlA8Rr5hayHZPJ9PQwwBgajyyjzfPxPPuSxwNGIMhxSElwv6/Nq Q9g9oR8S/AmmlrgyBX9/kvdV9yY724bPCsx1CufMynORyHJEcb5vJSkJRW+Pn1KbLZ7l w850QuMotuRiZuOV/vRlP6toBnklmf/WCJMi/hhJzmS2C9IJOOynN/isUA1KMFvslRES Qdmw== 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 59-v6si4314217wrp.220.2018.05.17.05.40.51; Thu, 17 May 2018 05:40:52 -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 6422D68A448; Thu, 17 May 2018 15:40:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-2.mx.upcmail.net (vie01a-qmta-pe01-2.mx.upcmail.net [62.179.121.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 76A9668A369 for ; Thu, 17 May 2018 15:40:04 +0300 (EEST) Received: from [172.31.218.35] (helo=vie01a-dmta-pe02-2.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fJID5-0003Kl-0h for ffmpeg-devel@ffmpeg.org; Thu, 17 May 2018 14:40:43 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fJICy-0003p6-VH for ffmpeg-devel@ffmpeg.org; Thu, 17 May 2018 14:40:36 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id nQgW1x04x0S5wYM01QgXfc; Thu, 17 May 2018 14:40:31 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 17 May 2018 14:38:58 +0200 Message-Id: <20180517123858.2940-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180517123858.2940-1-michael@niedermayer.cc> References: <20180517123858.2940-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/mlpdec: Only change noise_type if the related fields are valid 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: inconsistency Fixes:runtime error: index 8 out of bounds for type 'int32_t [8]' Fixes: 6686/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-5191383498358784 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mlpdec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 63ec3e64bd..8caa266b7e 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -479,7 +479,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, uint8_t checksum; uint8_t lossless_check; int start_count = get_bits_count(gbp); - int min_channel, max_channel, max_matrix_channel; + int min_channel, max_channel, max_matrix_channel, noise_type; const int std_max_matrix_channel = m->avctx->codec_id == AV_CODEC_ID_MLP ? MAX_MATRIX_CHANNEL_MLP : MAX_MATRIX_CHANNEL_TRUEHD; @@ -492,9 +492,9 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, return AVERROR_INVALIDDATA; } - s->noise_type = get_bits1(gbp); + noise_type = get_bits1(gbp); - if (m->avctx->codec_id == AV_CODEC_ID_MLP && s->noise_type) { + if (m->avctx->codec_id == AV_CODEC_ID_MLP && noise_type) { av_log(m->avctx, AV_LOG_ERROR, "MLP must have 0x31ea sync word.\n"); return AVERROR_INVALIDDATA; } @@ -520,7 +520,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, /* This should happen for TrueHD streams with >6 channels and MLP's noise * type. It is not yet known if this is allowed. */ - if (max_channel > MAX_MATRIX_CHANNEL_MLP && !s->noise_type) { + if (max_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) { avpriv_request_sample(m->avctx, "%d channels (more than the " "maximum supported by the decoder)", @@ -537,6 +537,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, s->min_channel = min_channel; s->max_channel = max_channel; s->max_matrix_channel = max_matrix_channel; + s->noise_type = noise_type; if (mlp_channel_layout_subset(m->avctx->request_channel_layout, s->mask) && m->max_decoded_substream > substr) {