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 ADFC0490F4 for ; Sat, 3 Feb 2024 17:22:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A2C5768D08E; Sat, 3 Feb 2024 19:22:05 +0200 (EET) Received: from sender21-mail.zoho.eu (sender11-op-o12.zoho.eu [31.186.226.226]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 384A068C954 for ; Sat, 3 Feb 2024 19:21:59 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; t=1706980915; cv=none; d=zohomail.eu; s=zohoarc; b=UGAOhMRgghjBmrHy3EoE/dlkQoyuCR0V3wMKPw5zLmsF93IScHtGZ4kSWy/pU8QjhAKyt/+VZEpWbyiMnboZ7je38hjc5atXIhl3yhdp3eEEwhEV6hpjO4HqoPKwd4corXysR4Vn259qczaKy9OAfk9jqS7+32a2uM/1k0Hvd5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1706980915; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=pLwdRzXOwK0IRiU8JjIt0zncUjJsFK5A1AeQCnJuMYk=; b=QSOFxKDIVkmfFNsxmxC+9TfxH8xsXZb/c1w5muz7Y1Gq8Hzcx1r+l9NTIq8GC5o8XB2HMGczbP9JBXqjAUTh6+rx6vZC51rlYcPS+nBZEo0uVVVlMMtFkHjctbCCGf98wspQ4/8Q4lF0J45UkQBswZblJg92q2JQMlJP+V1KoAY= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=frankplowman.com; spf=pass smtp.mailfrom=post@frankplowman.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1706980915; s=zmail; d=frankplowman.com; i=post@frankplowman.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=pLwdRzXOwK0IRiU8JjIt0zncUjJsFK5A1AeQCnJuMYk=; b=MwMNu1fSRSeQabA/Ttkm7/JvFTHV+M95RESg7CXPWuKx2g70PBg/NNhombHbwMbn 07lGDeOSZFyBkLceQN1pXf19U+7FHtTqXHjDZ1D21Fhj9jpIXVdB8+crIYZh4O2YLL+ 7dQnnd+6nlquGWVSXbBssRucPN36NlTQjxoQ+u7s= Received: from localhost.localdomain (185.175.219.1 [185.175.219.1]) by mx.zoho.eu with SMTPS id 1706980913529412.04446234216243; Sat, 3 Feb 2024 18:21:53 +0100 (CET) From: post@frankplowman.com To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Feb 2024 18:21:09 +0100 Message-ID: <20240203172109.20149-1-post@frankplowman.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-ZohoMailClient: External Subject: [FFmpeg-devel] [PATCH] lavc/vvc: Validate alf_list indexes 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: Frank Plowman 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: From: Frank Plowman Fixes crashes when decoding illegal bitstreams found by fuzzing. Signed-off-by: Frank Plowman --- libavcodec/vvc/vvc_ctu.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libavcodec/vvc/vvc_ctu.c b/libavcodec/vvc/vvc_ctu.c index d166b16a19..f601c6c95e 100644 --- a/libavcodec/vvc/vvc_ctu.c +++ b/libavcodec/vvc/vvc_ctu.c @@ -2207,7 +2207,7 @@ static void hls_sao(VVCLocalContext *lc, const int rx, const int ry) } } -static void alf_params(VVCLocalContext *lc, const int rx, const int ry) +static int alf_params(VVCLocalContext *lc, const int rx, const int ry) { const VVCFrameContext *fc = lc->fc; const H266RawSliceHeader *sh = lc->sc->sh.r; @@ -2233,6 +2233,11 @@ static void alf_params(VVCLocalContext *lc, const int rx, const int ry) c_idx == CB ? sh->sh_alf_cb_enabled_flag : sh->sh_alf_cr_enabled_flag; if (alf_enabled_flag) { const VVCALF *aps = fc->ps.alf_list[sh->sh_alf_aps_id_chroma]; + if (!aps) { + // Slice header refers to an APS which does not exist + return AVERROR_INVALIDDATA; + } + alf->ctb_flag[c_idx] = ff_vvc_alf_ctb_flag(lc, rx, ry, c_idx); alf->alf_ctb_filter_alt_idx[c_idx - 1] = 0; if (alf->ctb_flag[c_idx] && aps->num_chroma_filters > 1) @@ -2247,10 +2252,16 @@ static void alf_params(VVCLocalContext *lc, const int rx, const int ry) alf->ctb_cc_idc[i] = 0; if (cc_enabled[i]) { const VVCALF *aps = fc->ps.alf_list[cc_aps_id[i]]; + if (!aps) { + // Slice header refers to an APS which does not exist + return AVERROR_INVALIDDATA; + } alf->ctb_cc_idc[i] = ff_vvc_alf_ctb_cc_idc(lc, rx, ry, i, aps->num_cc_filters[i]); } } } + + return 0; } static void deblock_params(VVCLocalContext *lc, const int rx, const int ry) @@ -2274,7 +2285,9 @@ static int hls_coding_tree_unit(VVCLocalContext *lc, memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); hls_sao(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); - alf_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); + ret = alf_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); + if (ret < 0) + return ret; deblock_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); if (IS_I(rsh) && sps->r->sps_qtbtt_dual_tree_intra_flag) -- 2.43.0 _______________________________________________ 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".