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 02C30449FB for ; Thu, 29 Sep 2022 14:10:35 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BB8D068BA6C; Thu, 29 Sep 2022 17:10:32 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 671FE68B389 for ; Thu, 29 Sep 2022 17:10:26 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A03B5240183 for ; Thu, 29 Sep 2022 16:10:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id e72WJ_--OlNp for ; Thu, 29 Sep 2022 16:10:25 +0200 (CEST) Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 0BB9B2400F4 for ; Thu, 29 Sep 2022 16:10:25 +0200 (CEST) Received: by lain.khirnov.net (Postfix, from userid 1000) id 8F3E91601B2; Thu, 29 Sep 2022 16:10:22 +0200 (CEST) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20220928223509.GB6583@pb2> References: <20220922180852.20655-1-michael@niedermayer.cc> <166437816569.22057.983964854773409478@lain.khirnov.net> <20220928223509.GB6583@pb2> Mail-Followup-To: FFmpeg development discussions and patches Date: Thu, 29 Sep 2022 16:10:22 +0200 Message-ID: <166446062255.22057.14060430318465734011@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 1/2] avformat/vividas: Check packet 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-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: Quoting Michael Niedermayer (2022-09-29 00:35:09) > On Wed, Sep 28, 2022 at 05:16:05PM +0200, Anton Khirnov wrote: > > Quoting Michael Niedermayer (2022-09-22 20:08:51) > > > Fixes: signed integer overflow: 119760682 - -2084600173 cannot be represented in type 'int' > > > Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6745781167587328 > > > > > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > > Signed-off-by: Michael Niedermayer > > > --- > > > libavformat/vividas.c | 13 +++++++++++-- > > > 1 file changed, 11 insertions(+), 2 deletions(-) > > > > > > diff --git a/libavformat/vividas.c b/libavformat/vividas.c > > > index e9954f73ed0..e8efe49a5c0 100644 > > > --- a/libavformat/vividas.c > > > +++ b/libavformat/vividas.c > > > @@ -683,6 +683,7 @@ static int viv_read_packet(AVFormatContext *s, > > > > > > if (viv->sb_entries[viv->current_sb_entry].flag == 0) { > > > uint64_t v_size = ffio_read_varlen(pb); > > > + int last, last_start; > > > > > > if (!viv->num_audio) > > > return AVERROR_INVALIDDATA; > > > @@ -704,14 +705,22 @@ static int viv_read_packet(AVFormatContext *s, > > > start = ffio_read_varlen(pb); > > > pcm_bytes = ffio_read_varlen(pb); > > > > > > - if (i > 0 && start == 0) > > > - break; > > > + if (i > 0) { > > > + if (start == 0) > > > + break; > > > + if (start < last || start - (unsigned)last > INT_MAX) > > > > What is the second condition for? > > start is signed int so are "copyies" of it > "start < last" would allow a negative last with a large start > the 2nd check handles that. > the difference of consequtive values are stored as int later > > The patch tried to leave the storage types and check for it. > The types could be changed or some other checks could be used > I was undecided on this patch a bit too. I picked this mainly > to keep changes more minimal but maybe this was not the best > choice Checking that start >= 0 would fix this as well, wouldn't it? I don't think it makes sense for it to be negative. -- Anton Khirnov _______________________________________________ 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".