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 E6FFC40C9E for ; Sun, 6 Nov 2022 12:29:16 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 606DD68B586; Sun, 6 Nov 2022 14:29:13 +0200 (EET) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3D5C568B04D for ; Sun, 6 Nov 2022 14:29:07 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 25016100002 for ; Sun, 6 Nov 2022 12:29:05 +0000 (UTC) Date: Sun, 6 Nov 2022 13:29:05 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20221106122905.GU1814017@pb2> References: <20221105201629.1980-1-michael@niedermayer.cc> <20221105201629.1980-3-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 3/4] avcodec/bonk: Check unquant for overflow 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: multipart/mixed; boundary="===============2483026775992812268==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2483026775992812268== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Wlbg71WMOPzcvmIn" Content-Disposition: inline --Wlbg71WMOPzcvmIn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Nov 06, 2022 at 09:51:57AM +0100, Paul B Mahol wrote: > On 11/5/22, Michael Niedermayer wrote: > > Fixes: signed integer overflow: -2889074 * 2048 cannot be represented in > > type 'int' > > Fixes: > > 51363/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-566= 0734784143360 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/bonk.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/libavcodec/bonk.c b/libavcodec/bonk.c > > index 471e09fe14..1695229dbd 100644 > > --- a/libavcodec/bonk.c > > +++ b/libavcodec/bonk.c > > @@ -363,12 +363,17 @@ static int bonk_decode(AVCodecContext *avctx, AVF= rame > > *frame, > > return ret; > > > > for (int i =3D 0; i < samples_per_packet; i++) { > > + int64_t t64; > > for (int j =3D 0; j < s->down_sampling - 1; j++) { > > sample[0] =3D predictor_calc_error(s->k, state, s->n_t= aps, > > 0); > > sample++; > > } > > > > - sample[0] =3D predictor_calc_error(s->k, state, s->n_taps, > > s->input_samples[i] * quant); > > + t64 =3D s->input_samples[i] * (int64_t)quant; > > + if ((int32_t)t64 !=3D t64) > > + return AVERROR_INVALIDDATA; > > + > > + sample[0] =3D predictor_calc_error(s->k, state, s->n_taps,= t64); > > sample++; > > } > > >=20 > NAK, using int64_t and thus slowing things down. this code has little speed relevance, a single interation of this loop takes over 1300 cpu cycles already and it is faster, why, no clue, i guess it maybe reshuffles some speed relevant bits int 13145422 decicycles in QUA, 8192 runs, 0 skips 13175400 decicycles in QUA, 8192 runs, 0 skips 13260076 decicycles in QUA, 8192 runs, 0 skips int64 13049729 decicycles in QUA, 8192 runs, 0 skips 13049418 decicycles in QUA, 8192 runs, 0 skips 13038855 decicycles in QUA, 8192 runs, 0 skips=20 [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting. --Wlbg71WMOPzcvmIn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY2eoigAKCRBhHseHBAsP q58sAJ9TzvcTzuHE58FznYS21/e3TpGgkwCfUEmMT1YfiydrKeoNNB7A3zaoIdE= =pt5I -----END PGP SIGNATURE----- --Wlbg71WMOPzcvmIn-- --===============2483026775992812268== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============2483026775992812268==--