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 595AC45D7C for ; Sun, 9 Apr 2023 14:26:47 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 72B9B68BCDA; Sun, 9 Apr 2023 17:26:37 +0300 (EEST) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5F63568087A for ; Sun, 9 Apr 2023 17:26:30 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 86A2620007 for ; Sun, 9 Apr 2023 14:26:29 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 9 Apr 2023 16:26:23 +0200 Message-Id: <20230409142627.19820-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230409142627.19820-1-michael@niedermayer.cc> References: <20230409142627.19820-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/6] avcodec/hevc_ps: Check num_ref_loc_offsets 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: Writing arbitrarily over the array end Fixes: 57812/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4536557859373056 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/hevc_ps.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 348e4d8de2d..be1d668c263 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -1392,6 +1392,10 @@ static int pps_multilayer_extension(GetBitContext *gb, AVCodecContext *avctx, pps->pps_scaling_list_ref_layer_id = get_bits(gb, 6); pps->num_ref_loc_offsets = get_ue_golomb_long(gb); + if (pps->num_ref_loc_offsets > FF_ARRAY_ELEMS(pps->ref_loc_offset_layer_id)) { + pps->num_ref_loc_offsets = 0; + return AVERROR_INVALIDDATA; + } for (int i = 0; i < pps->num_ref_loc_offsets; i++) { pps->ref_loc_offset_layer_id[i] = get_bits(gb, 6); pps->scaled_ref_layer_offset_present_flag[i] = get_bits1(gb); -- 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".