From patchwork Thu Sep 21 18:09:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 43870 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:38a7:b0:15d:8365:d4b8 with SMTP id n39csp310376pzf; Thu, 21 Sep 2023 11:10:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeRX4CnCyxd5GM2TpO++VHXOPhEid1B//pQ1FYJnt7TwaAqV/EuLxn9V/0MSjj/oiXLksW X-Received: by 2002:aa7:c519:0:b0:532:bc4d:9076 with SMTP id o25-20020aa7c519000000b00532bc4d9076mr5577516edq.19.1695319803882; Thu, 21 Sep 2023 11:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695319803; cv=none; d=google.com; s=arc-20160816; b=iNmj12bBBxkYEkfFRlj0f9mM5/RhlL86XM1LSdOTPn8e67LUgKcw7WlfTUmkMUO9vT y94fuEU5tnl4CJNQ1e65jiJElNe/4Pzaq/KqHI1VYREWGCACaXFTOcgxT4gjhtttiYlP SK2EV4SEmnFykbM7RCKsydTWldDtY6adZr4hAM7N4LBTlCKmwCGKhd0tzkSJL3QIj6Vi IvCw/PrDpAB+LeUYK0cNuxP6yptrhzrIa+C/K0kqYi29PF3PdfrYIKDgJSqUyu+xIUr2 j0q5LLsEnPHBNic4Ryx08/hJXv8RZuTdSfivFG9xa/iCe8V+Qu4DEftKEfRMXHjJm/XV cgVw== 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=OlgXyed/n8NRy2fWyRBBEjp5VGQHOs5KEJ04bv4M5sc=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=AW489Q+HUshaps4tdFsFeugxHxbeMcdh3aKl8fOChiApPAICnejbACMtqJoWVu7v+b prJa/hoWUqkZteUZ/uTMcjZPjdYc/5EKn+L6YrOhws15NQFwXCUo8dR2qUBRkbvLiDQp CV7kZOcSSGSSAJVS8ti7w8gTETQljmzRNZfVLDWLXQLd8bpVZX5VVEjJEL7vsvKDLkFx fv6sBUsXxMHwOqhZ7xwQdLL6vInapxITl9n7iFVPXqZ0i21fkekIoO8QAQhuS/WimBew FxqDagCGhmL1deNSVckCowTQlk7bELPZtipVTeC41a8fL0eYo1yoqljZjdAYzujnEMMU boQg== 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 s20-20020aa7d794000000b005313e7997d2si1604290edq.556.2023.09.21.11.10.03; Thu, 21 Sep 2023 11:10:03 -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 6DF6868C949; Thu, 21 Sep 2023 21:09:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5B88A68C927 for ; Thu, 21 Sep 2023 21:09:18 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 88BF960007 for ; Thu, 21 Sep 2023 18:09:17 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 21 Sep 2023 20:09:11 +0200 Message-Id: <20230921180912.10733-5-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230921180912.10733-1-michael@niedermayer.cc> References: <20230921180912.10733-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 5/6] avcodec/jpegxl_parse: Cleanup on error in read_vlc_prefix() 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: H/ceyZwq/ZWw Fixes: leak Fixes: 62164/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6167847715602432 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/jpegxl_parser.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c index 6656ed35c51..17e87d5cc34 100644 --- a/libavcodec/jpegxl_parser.c +++ b/libavcodec/jpegxl_parser.c @@ -777,8 +777,10 @@ static int read_vlc_prefix(GetBitContext *gb, JXLEntropyDecoder *dec, JXLSymbolD } } - if (total_code != 32768 && level2_codecounts[0] < dist->alphabet_size - 1) - return AVERROR_INVALIDDATA; + if (total_code != 32768 && level2_codecounts[0] < dist->alphabet_size - 1) { + ret = AVERROR_INVALIDDATA; + goto end; + } for (int i = 1; i < dist->alphabet_size + 1; i++) level2_codecounts[i] += level2_codecounts[i - 1];