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 7926A446F4 for ; Wed, 21 Sep 2022 09:43:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1994968BB7D; Wed, 21 Sep 2022 12:43:31 +0300 (EEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AA95B68BAB7 for ; Wed, 21 Sep 2022 12:43:23 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663753408; x=1695289408; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=37F9ORzzCOpFgDWy0vJUJGhdCac35UM9PgJeBvRRljU=; b=cSgBIvdJ5YQ+fmZuT5DDhDYrZnsGyaECfxwy3cBzYx3ppPNYhcxLDnHk RMe766ntDqZ6KYE/Z1VPrZSttyVjREQzlyOrirQqPrLkybi0tTaGKKTtA Aky7dAOVhA1Y1bVUmgS+k6bv4RaXmIeluFhT5i66+rJFLpNQaohyryepe yTtFbw7F8O07ilY9kLjFOHAvKSIWBFzElTsy77Lyty2q7gHNdFTISFp6C EFKzAmm0i9+lYVeoXYPdBjg02O/ixBMyjJtA2aTD86l702M1HhMzm6Dg2 GljGA4WQnIehZ133gV5mAqK2BjA+Y4YvYUovbe9L5+ukATQZAdPeUPeTy A==; X-IronPort-AV: E=McAfee;i="6500,9779,10476"; a="386240661" X-IronPort-AV: E=Sophos;i="5.93,333,1654585200"; d="scan'208";a="386240661" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2022 02:43:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,333,1654585200"; d="scan'208";a="687801439" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by fmsmga004.fm.intel.com with ESMTP; 21 Sep 2022 02:43:20 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Wed, 21 Sep 2022 17:41:24 +0800 Message-Id: <20220921094124.1749099-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4] libavcodec/cbs_av1: Add size check before parse obu 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-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: cbs_av1_write_obu() check pbc size after parsing obu frame, and return AVERROR(ENOSPC) if pbc is small. pbc will be reallocated and this obu frame will be parsed again, but this may cause error because CodedBitstreamAV1Context has already been updated, for example ref_order_hint is updated and will not match the same obu frame. Now size check is added before parsing obu frame to avoid this error. Signed-off-by: Wenbin Chen --- libavcodec/cbs_av1.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index 154d9156cf..9c51a8c7c8 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -1075,6 +1075,9 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, put_bits32(pbc, 0); } + if (8 * (unit->data_size + obu->obu_size) > put_bits_left(pbc)) + return AVERROR(ENOSPC); + td = NULL; start_pos = put_bits_count(pbc); -- 2.32.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".