From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 9DE0548002 for ; Wed, 8 Nov 2023 02:13:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BCE1C68CB91; Wed, 8 Nov 2023 04:12:54 +0200 (EET) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8E83968CB03 for ; Wed, 8 Nov 2023 04:12:48 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id BFBE9240002 for ; Wed, 8 Nov 2023 02:12:47 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 8 Nov 2023 03:12:44 +0100 Message-Id: <20231108021244.8669-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231108021244.8669-1-michael@niedermayer.cc> References: <20231108021244.8669-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/jpegxl_parser: Check get_vlc2() 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Fixes: shift exponent -1 is negative Fixes: 63889/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6009343056936960 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/jpegxl_parser.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c index 630fc8a60bf..964f5a9ad5a 100644 --- a/libavcodec/jpegxl_parser.c +++ b/libavcodec/jpegxl_parser.c @@ -698,6 +698,10 @@ static int read_vlc_prefix(GetBitContext *gb, JXLEntropyDecoder *dec, JXLSymbolD level1_codecounts[0] = hskip; for (int i = hskip; i < 18; i++) { len = level1_lens[prefix_codelen_map[i]] = get_vlc2(gb, level0_table, 4, 1); + if (len < 0) { + ret = AVERROR_INVALIDDATA; + goto end; + } level1_codecounts[len]++; if (len) { total_code += (32 >> len); @@ -743,6 +747,10 @@ static int read_vlc_prefix(GetBitContext *gb, JXLEntropyDecoder *dec, JXLSymbolD total_code = 0; for (int i = 0; i < dist->alphabet_size; i++) { len = get_vlc2(gb, level1_vlc.table, 5, 1); + if (len < 0) { + ret = AVERROR_INVALIDDATA; + goto end; + } if (get_bits_left(gb) < 0) { ret = AVERROR_BUFFER_TOO_SMALL; goto end; -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".