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 47A164A71D for ; Thu, 4 Apr 2024 17:12:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C41268D0DD; Thu, 4 Apr 2024 20:12:52 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3827868CA66 for ; Thu, 4 Apr 2024 20:12:45 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D9EA3EA2B2 for ; Thu, 4 Apr 2024 19:12:43 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aAI1ClBOAvah for ; Thu, 4 Apr 2024 19:12:40 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 298BAEA236 for ; Thu, 4 Apr 2024 19:12:40 +0200 (CEST) Date: Thu, 4 Apr 2024 19:12:40 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20240403225134.31764-5-michael@niedermayer.cc> Message-ID: <956d190b-ccde-74af-aebc-77667f9108ca@passwd.hu> References: <20240403225134.31764-1-michael@niedermayer.cc> <20240403225134.31764-5-michael@niedermayer.cc> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 5/5] avformat/pcm: Use 64bit in bitrate computation 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 Thu, 4 Apr 2024, Michael Niedermayer wrote: > Fixes: signed integer overflow: 65792 * 65312 cannot be represented in type 'int' > Fixes: 67819/clusterfuzz-testcase-minimized-ffmpeg_dem_WADY_fuzzer-5236100912185344 > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavformat/pcm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/pcm.c b/libavformat/pcm.c > index 051e86dd464..a774dbc3726 100644 > --- a/libavformat/pcm.c > +++ b/libavformat/pcm.c > @@ -41,7 +41,7 @@ int ff_pcm_default_packet_size(AVCodecParameters *par) > /* Don't trust the codecpar bitrate if we can calculate it ourselves */ > if (bits_per_sample > 0 && par->sample_rate > 0 && par->ch_layout.nb_channels > 0) > if ((int64_t)par->sample_rate * par->ch_layout.nb_channels < INT64_MAX / bits_per_sample) > - bitrate = bits_per_sample * par->sample_rate * par->ch_layout.nb_channels; > + bitrate = bits_per_sample * (int64_t)par->sample_rate * par->ch_layout.nb_channels; LGTM, thanks. I wonder why we usually cast the second operand and not the first to 64 bit, since cast has higher precedence than multiplication, it should not matter, should it? Regards, Marton _______________________________________________ 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".