From patchwork Thu Oct 12 23:27:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44235 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4b15:b0:15d:8365:d4b8 with SMTP id fp21csp660515pzb; Thu, 12 Oct 2023 16:28:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGUDHJc+3CV7nN9qNYKYD8Mdic8QbhwbDN+cLxGqDb7o6puTAFpbQUP31Fq0vROxKn+QiVX X-Received: by 2002:adf:d1ca:0:b0:329:6dbc:e9a8 with SMTP id b10-20020adfd1ca000000b003296dbce9a8mr19866633wrd.8.1697153308046; Thu, 12 Oct 2023 16:28:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697153308; cv=none; d=google.com; s=arc-20160816; b=XgF2WvXXUGXlQgPtef9UrYZg+xVO64K0Gj+AiIaKZ6+9EYtEXqKUjfXkMKxYiXiNjc ySMi3rPU9Y9sVql7Mcc+8t0ZtK5kNOZn/Pvo1uB7Q3rBYLum3RcVs6o9qEvHMBJpkXDB 1XAGOm3iLmWqBmTjsBFgxXGDVKKku2RLAFanV4wJGyk9nDIJ+Lo4t/8m5Iqld/vT8hk0 juz/LarK6wXrpSQbRWzscfuxZYPevGBtv8wfATSr/afHPo8FLkWuEh6809F6FJT7kU00 559td4xQTRgJcSBdkmBbSupJzpCFRnoh3a6Ui6OV8Qa8SbqH+dBJyn2Gu0YQBTwRUZW7 mjhw== 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; bh=WkmFiC8aAg0KmyzYRsh+hJUSgPk3vNTbVHs2GHav7Pk=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=BUgCULb0L4ZHsKtB7hXo0ta37lLhMVtJKg8fRb23OT9LwiALIz4QofhIyclEZEnAHi i1eokP2zbaFeZeMwrJNKK5cTLs5D+RlGfd2CKk7soDmEZPO1XRnjmDrPxWU9ICJ+jENs 446bPgw0f+7JMn65BusJoqeka9gDaVo+jcz7jck/NIbr4jKqhgaf/9FxRjF0Fg7cWV2h s82SUs1AbFm4KLy3Tqu70QWZ9f04m6D1PvxDesc8Dxeqg0RGNzBI/5PZwqJhI5vhDZgy xWt8yhQSqmn6UwbYvwzQ0NWjOW6hOft5GU+Ixe08bYPdSCwcLn3OyX/hNcFC4m0FCG4O qJGQ== 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 g20-20020a1709064e5400b0099bd53a0d3csi7895900ejw.178.2023.10.12.16.28.27; Thu, 12 Oct 2023 16:28:28 -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 2AC9B68C9F8; Fri, 13 Oct 2023 02:28:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 324B568C76B for ; Fri, 13 Oct 2023 02:28:03 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7F6621BF206 for ; Thu, 12 Oct 2023 23:28:02 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 13 Oct 2023 01:27:59 +0200 Message-Id: <20231012232759.5352-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231012232759.5352-1-michael@niedermayer.cc> References: <20231012232759.5352-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/evc_parse: Check tid 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: z6WiNjnes2h2 The check is based on not infinite looping. It is likely a more strict check can be done Fixes: Infinite loop Fixes: 62473/clusterfuzz-testcase-minimized-ffmpeg_BSF_EVC_FRAME_MERGE_fuzzer-5719883750703104 Fixes: 62765/clusterfuzz-testcase-minimized-ffmpeg_dem_EVC_fuzzer-6448531252314112 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/evc_parse.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c index 255706ce61..43b8dabf8b 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -174,6 +174,9 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, } else { int SubGopLength = 1 << sps->log2_sub_gop_length; + if (tid > (SubGopLength > 1 ? 1 + av_log2(SubGopLength - 1) : 0)) + return AVERROR_INVALIDDATA; + if (tid == 0) { poc->PicOrderCntVal = poc->prevPicOrderCntVal + SubGopLength; poc->DocOffset = 0;