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 284E94068E for ; Wed, 22 Dec 2021 13:34:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 82F4C68B086; Wed, 22 Dec 2021 15:34:21 +0200 (EET) Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 51E2A68B084 for ; Wed, 22 Dec 2021 15:34:14 +0200 (EET) Received: from smtp102.mailbox.org (smtp102.mailbox.org [80.241.60.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4JJvS539l9zQlZj for ; Wed, 22 Dec 2021 14:34:13 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Message-ID: <96321e9e-391b-40f8-cacd-613f7dbef9d5@gyani.pro> Date: Wed, 22 Dec 2021 19:03:57 +0530 MIME-Version: 1.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20211222124728.7300-1-ffmpeg@gyani.pro> From: Gyan Doshi In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/mov: add validate_box_size 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 2021-12-22 06:43 pm, Nicolas George wrote: > Gyan Doshi (12021-12-22): >> Helper function to check if stored box size is correct and looks >> to be fully available. >> --- >> libavformat/mov.c | 34 ++++++++++++++++++++++++++++++++++ >> 1 file changed, 34 insertions(+) >> >> diff --git a/libavformat/mov.c b/libavformat/mov.c >> index 2aed6e80ef..7de95b7ab0 100644 >> --- a/libavformat/mov.c >> +++ b/libavformat/mov.c >> @@ -80,6 +80,40 @@ static int mov_read_mfra(MOVContext *c, AVIOContext *f); >> static int64_t add_ctts_entry(MOVCtts** ctts_data, unsigned int* ctts_count, unsigned int* allocated_size, >> int count, int duration); >> >> +/** Check if the box size meets the requirements passed in limit and constraint_type. >> + * If input avio_size is valid, it checks if box size appears to be available. >> + * >> + * constraint_type may be >> + * 0 if the box size has to be exactly equal to limit >> + * -1 if the box size has to be at most limit >> + * 1 if the box size has to be at least limit >> + * >> + * Returns 0 if size meets requirements. >> + */ >> +static int validate_box_size(MOVContext *c, MOVAtom atom, AVIOContext *pb, >> + int64_t pos, int64_t limit, int constraint_type) >> +{ >> + int size_fit; >> + int64_t input_size = avio_size(pb); >> + >> + if (input_size > 0 && >> + input_size - pos < atom.size) { >> + av_log(c->fc, AV_LOG_ERROR, "Box %s is truncated\n", av_fourcc2str(atom.type)); >> + return AVERROR_INVALIDDATA; >> + } >> + >> + if (FFABS(constraint_type) > 1) >> + return AVERROR_BUG; > av_assert() whould have been the right choice here. Will change. > >> + >> + switch(constraint_type) { >> + case 0: size_fit = atom.size == limit; break; >> + case -1: size_fit = atom.size <= limit; break; >> + case 1: size_fit = atom.size >= limit; break; > This code is unused, AFAICS. Not a good idea. I'll call this function in other box readers. Their requirements are different. That's why I made the check a separate function. Regards, Gyan _______________________________________________ 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".