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 5618546FF0 for ; Tue, 25 Jul 2023 01:54:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D997068C829; Tue, 25 Jul 2023 04:54:31 +0300 (EEST) Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D095D68C068 for ; Tue, 25 Jul 2023 04:54:24 +0300 (EEST) Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6bb140cd5a5so2638468a34.3 for ; Mon, 24 Jul 2023 18:54:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690250062; x=1690854862; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Llrkc/Oe5NeDsTT6JwCErkHR0lipNVsIc4/y8S+gfMw=; b=kzYsk2X8wwMrjaKBaDWX+iZ0Rl+AOxoqnbOsYpe5oM8VLOH5Pk0gM6gjxBUpm7Zozg QI1EzFlN6iQitvI98tM/7NkNnqRiy7DMNLMXZJZblTW1XGm5jlzfRolJXx1zz7FfCGz1 XzEPxBtZp4v3M6TfU2dDGnPaTZ37sBoi4Ij/6Bd//PPcEr4gTc2C/e8EAr7XV6cmaRiJ +7Q6ClZqBc8l90fCsinSSolA4ap/7ciBl83BqGJmNAm3LlkKRiCnCHfLlzaf3YOZYn4l hTjIPbf71PZCktMNrEf0ffKa2tGBB5chAK+Wea2qaEhs2qvxTWuT509uAB9e7MFPjvXV 2RNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690250062; x=1690854862; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Llrkc/Oe5NeDsTT6JwCErkHR0lipNVsIc4/y8S+gfMw=; b=BbzNmfWKCemBIP1cix4IVWyqAm9+jLxJrepGKDbRbpFRP0PqzjDEAlSFioaEGvoORZ EPk3tVdKMBL42ELsT8ES+5vicQCAUXMc+HvJLYQfUUte2uBJmOHnGMeF9zlansqhNMuQ HFHJCFs5vLAJcbml29qEC66k0xG51D5uHIygl+0EfwwGdyA1AGusudREuMdMtBC+hKAa 9xi8IoihFwTRl7PeATOEwCNVoomLpH3lqYUm/MAI7JWW4YV0R9W9j1tue1nncsP/Oov6 FTsfh9Yych+JFUFIjSGEo7UCkjrEmk1I5C4aGyqCR13wWy+BRbymUz0rLJz3kvfah3F1 kQYA== X-Gm-Message-State: ABy/qLacxB/R8pm05w2r+xceDLgQ+6iQP/Cf+f8jwchYPDPEgdgPKYI8 fZFH7IK3mK1YeVzyO0OEly9qHmrL69U= X-Google-Smtp-Source: APBJJlGmIwk+qpBoQ9UTaL4uXwOHno1I4QNCeR7OmEt05fqkc+g6R2oMS2gdVCqfx+4yW90tqvhgMA== X-Received: by 2002:a05:6870:9a26:b0:1b0:3a8c:a7fe with SMTP id fo38-20020a0568709a2600b001b03a8ca7femr14445685oab.30.1690250062171; Mon, 24 Jul 2023 18:54:22 -0700 (PDT) Received: from [192.168.0.16] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id y23-20020a4ad657000000b00563155bd360sm4560239oos.17.2023.07.24.18.54.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jul 2023 18:54:21 -0700 (PDT) Message-ID: Date: Mon, 24 Jul 2023 22:54:20 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20230725004609.17750-1-michael@niedermayer.cc> <20230725004609.17750-2-michael@niedermayer.cc> From: James Almer In-Reply-To: <20230725004609.17750-2-michael@niedermayer.cc> Subject: Re: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_h266_syntax_template: Check num_subpic_cols for 0 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 7/24/2023 9:46 PM, Michael Niedermayer wrote: > Fixes: division by zero > Fixes: 60306/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5538913553612800 > > 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 | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c > index dce0216fbc..18ecf17e3b 100644 > --- a/libavcodec/cbs_h266_syntax_template.c > +++ b/libavcodec/cbs_h266_syntax_template.c > @@ -1187,6 +1187,8 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, > } else { > int num_subpic_cols = tmp_width_val / > (current->sps_subpic_width_minus1[0] + 1); > + if (!num_subpic_cols) > + return AVERROR_INVALIDDATA; > infer(sps_subpic_ctu_top_left_x[i], > (i % num_subpic_cols) * > (current->sps_subpic_width_minus1[0] + 1)); Does the following fix it too? > diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c > index dce0216fbc..98a8e033bf 100644 > --- a/libavcodec/cbs_h266_syntax_template.c > +++ b/libavcodec/cbs_h266_syntax_template.c > @@ -1140,6 +1140,8 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, > if (current->sps_num_subpics_minus1 > 0) { > int wlen = av_ceil_log2(tmp_width_val); > int hlen = av_ceil_log2(tmp_height_val); > + infer(sps_subpic_ctu_top_left_x[0], 0); > + infer(sps_subpic_ctu_top_left_y[0], 0); > if (current->sps_pic_width_max_in_luma_samples > ctb_size_y) > ubs(wlen, sps_subpic_width_minus1[0], 1, 0); > else > @@ -1147,7 +1149,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, > if (current->sps_pic_height_max_in_luma_samples > ctb_size_y) > ubs(hlen, sps_subpic_height_minus1[0], 1, 0); > else > - infer(sps_subpic_height_minus1[0], tmp_height_val); > + infer(sps_subpic_height_minus1[0], tmp_height_val - 1); > if (!current->sps_independent_subpics_flag) { > flags(sps_subpic_treated_as_pic_flag[0], 1, 0); > flags(sps_loop_filter_across_subpic_enabled_flag[0], 1, 0); > @@ -1187,6 +1189,12 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, > } else { > int num_subpic_cols = tmp_width_val / > (current->sps_subpic_width_minus1[0] + 1); > + if (tmp_width_val % (current->sps_subpic_width_minus1[0] + 1) || > + tmp_height_val % (current->sps_subpic_width_minus1[0] + 1) || > + current->sps_num_subpics_minus1 != > + (num_subpic_cols * tmp_height_val / > + (current->sps_subpic_height_minus1[0] + 1) - 1)) > + return AVERROR_INVALIDDATA; > infer(sps_subpic_ctu_top_left_x[i], > (i % num_subpic_cols) * > (current->sps_subpic_width_minus1[0] + 1)); This checks the constrains defined in the spec. _______________________________________________ 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".