From patchwork Wed Aug 25 03:06:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 29766 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp163658iov; Tue, 24 Aug 2021 20:06:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytlUU+RdJ7fUhrid4H+B8puumNCny67nALr/YrtRuAhsZDg3mNpexHwEWQ8GyCMqrQsGee X-Received: by 2002:a05:6402:b47:: with SMTP id bx7mr15270777edb.319.1629860801569; Tue, 24 Aug 2021 20:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629860801; cv=none; d=google.com; s=arc-20160816; b=akTAj6XBqjD7El1scHG/noyhMpZW/1Eruo0esTMLNcBxHhVTCJWEAg+Hb8fc1RzOkL yCWF9w+whJ1zkVpijAEIJgkL9p1xsv6Q5WmP7+gk+og9HtFqytpQeisADSj+aEjCi9S1 LMtfAn+I7YDevNSspsdjHxUIzGllVVTJw2/m3X2vvn1n0sZviXFDoY3HrDgUjRnw1mjN DJZwbVSP0dVOD+JxpVSadI4K+PzxkSn1kQPavukK2NN2JO2Qlk354Bzdut/g/KsF8hCA MnAE0WuuUCjn36WpPTjZvCC2j8jvMe7MHNFmrSPLzDFPhnQDPOr5ST/Vupam5gmpBI+W B9oQ== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=6CP/wnnJMeST/2pmzl2u6VR/hkY2wQV30bJCSznQY3k=; b=R7J4I1ynywLXzeN2ujGpNSaOQ1f8vrDV2PlaQAMaxF0ote9NgbpfnQV9WQVu8rVRm9 tabSc74yAVHkGOGmDwuWZNEovn8MREuuoHyOvGrvaUFLrljDCEu/Kz7cY3QAChIN/zSX shy9Za6GKuY72A+qumpFqshPyI9KsG7BXvh6QJ3zZeoST1flyN3bv2qqMFzzmY7JLB3c 87tKMWPbDbMi6zCVd3GtL2bvVWvdA3S5LsadsAeoAfgPLAz66EBtlMme+Go6Ek5h4ZQS O4WEoDAeCoamtz0xW4vN8sXvE+jTJ6+SKcya3x8e3hAHDMqgK9KoQbnWNWW6ilwR+Z9s QwEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="vg/u+Glq"; 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 h16si8451398edz.437.2021.08.24.20.06.18; Tue, 24 Aug 2021 20:06:41 -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; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="vg/u+Glq"; 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 883E868A22C; Wed, 25 Aug 2021 06:06:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4FADF68798E for ; Wed, 25 Aug 2021 06:06:07 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 13B6B475C6; Wed, 25 Aug 2021 05:06:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1629860766; bh=kbskmve8I4+vxBcz+am+XONTz8qUOV1FEOvIbjjWCcw=; h=From:To:Cc:Subject:Date:From; b=vg/u+GlqZxdcONYYfN8sfhlLqirL7hn7XF9dQEQRLuuHVDiF2ugiAju995+Wahv1Y Xo5MnI/nQ5DblMxR8uPxmUtlxLkHpeDeB+h5cILRgyvqj7Ka/y233yUQFQnF6VM/RC cdf6hJA35qOD0h2ciDbqnm1vNyTBpR38+dkiuego= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Aug 2021 05:06:01 +0200 Message-Id: <20210825030601.117793-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/h264dec: fix possible out-of-bounds array access X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: sbuDpAd+O5Te From: Niklas Haas If slice_type is > 9, the access to ff_h264_golomb_to_pict_type is out-of-bounds. Fix this by simply setting the slice_type to 0 in this case. This is completely inconsequential because the value is only being used to being used as an offset in the calculation of the film grain seed value, a corruption of which is practically invisible. Fixes coverity ticket #1490802 --- libavcodec/h264dec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 5e5b1c1d69..595b6c81fb 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -536,6 +536,7 @@ static int get_last_needed_nal(H264Context *h) if (slice_type > 9) { if (h->avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; + slice_type = 0; } if (slice_type > 4) slice_type -= 5;