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 DA3BE454BC for ; Sat, 27 Jan 2024 03:13:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1376168D126; Sat, 27 Jan 2024 05:13:40 +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 C79CC68CB6E for ; Sat, 27 Jan 2024 05:13:33 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id 1A809240003; Sat, 27 Jan 2024 03:13:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1706325213; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=AqZhCx2lb7YeqZsQvnFDXT8q39GSq+7eTey94aPjdTQ=; b=CJI0/tKJQE6uV7keYgi21NLboeP46BardC4WVuGXphdvci6/OChJDn8WTEowYWtlDV4EA7 +Y2m0u7AwY6EOsgb4Hf8weAOcGQ3QXQrtbBND38ZlFUWgSvLKY9OfVYRNkKxyiku4xNwJz 9s3iZWoFL8/od38Pxjjc+xuYQLtVoAAsRz2mT96PqLiYBulzPLAQFlVxoGcv22gfPxP5RR 0UfwFDmRFVy6+jvijpq0rGaAYrMP/6Kok4iQWXD9kc6DJrIsPqe2TugcrrEpR9b+JK1LQA lpOvVWknYBhGvVPRL4hOHaVxN3JbTJm96sWcwuvdJq53oRtzzAHszJDJH6mQOQ== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 27 Jan 2024 04:13:32 +0100 Message-Id: <20240127031332.17970-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH] avcodec/cbs_h266_syntax_template: check aps_adaptation_parameter_set_id 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: James Almer 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: From: James Almer "When aps_params_type is equal to ALF_APS or SCALING_APS, the value of aps_adaptation_parameter_set_id shall be in the range of 0 to 7, inclusive. When aps_params_type is equal to LMCS_APS, the value of aps_adaptation_parameter_set_id shall be in the range of 0 to 3, inclusive." Fixes: out of array accesses Fixes: 65932/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-4563412340244480 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/cbs_h266_syntax_template.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c index 9e479c9c314..21da8195556 100644 --- a/libavcodec/cbs_h266_syntax_template.c +++ b/libavcodec/cbs_h266_syntax_template.c @@ -2457,6 +2457,7 @@ static int FUNC(scaling_list_data)(CodedBitstreamContext *ctx, RWContext *rw, static int FUNC(aps)(CodedBitstreamContext *ctx, RWContext *rw, H266RawAPS *current, int prefix) { + int aps_id_max = MAX_UINT_BITS(5); int err; if (prefix) @@ -2469,7 +2470,12 @@ static int FUNC(aps)(CodedBitstreamContext *ctx, RWContext *rw, : VVC_SUFFIX_APS_NUT)); ub(3, aps_params_type); - ub(5, aps_adaptation_parameter_set_id); + if (current->aps_params_type == VVC_ASP_TYPE_ALF || + current->aps_params_type == VVC_ASP_TYPE_SCALING) + aps_id_max = 7; + else if (current->aps_params_type == VVC_ASP_TYPE_LMCS) + aps_id_max = 3; + u(5, aps_adaptation_parameter_set_id, 0, aps_id_max); flag(aps_chroma_present_flag); if (current->aps_params_type == VVC_ASP_TYPE_ALF) CHECK(FUNC(alf_data)(ctx, rw, current)); -- 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".