From: Michael Niedermayer <michael@niedermayer.cc> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH 05/11] avcodec/flacdec: Fix signed integre overflow Date: Sat, 6 May 2023 17:08:13 +0200 Message-ID: <20230506150813.GD4538@pb2> (raw) In-Reply-To: <cb0a1de4-63bc-b8cc-585a-daa075610d55@gmail.com> [-- Attachment #1.1: Type: text/plain, Size: 1993 bytes --] On Fri, May 05, 2023 at 07:36:05PM -0300, James Almer wrote: > On 4/16/2023 1:48 PM, Michael Niedermayer wrote: > > Fixes: signed integer overflow: 3011809745540902265 + 6323452730883571725 cannot be represented in type 'long' > > Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLAC_fuzzer-6687553022722048 > > > > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > > --- > > libavcodec/flacdec.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c > > index cc778a8dff1..524a0469495 100644 > > --- a/libavcodec/flacdec.c > > +++ b/libavcodec/flacdec.c > > @@ -513,7 +513,7 @@ static int decode_subframe_lpc_33bps(FLACContext *s, int64_t *decoded, > > for (i = pred_order; i < s->blocksize; i++, decoded++) { > > int64_t sum = 0; > > for (j = 0; j < pred_order; j++) > > - sum += (int64_t)coeffs[j] * decoded[j]; > > + sum += (int64_t)coeffs[j] * (uint64_t)decoded[j]; > > Why not instead do > > sum = av_sat_add64(sum, (int64_t)coeffs[j] * decoded[j]); Why should this be clipping ? flac is a lossless codec, i see nothing in the specification that calls for cliping. > > Also, decoded[j] is an int64_t, so wouldn't coeffs[j] be promoted if you > swap the order in the multiplication, thus saving the cast? it can be shuffled around to achieve the same, do you prefer coeffs[j] * (uint64_t)decoded[j]; ? thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Any man who breaks a law that conscience tells him is unjust and willingly accepts the penalty by staying in jail in order to arouse the conscience of the community on the injustice of the law is at that moment expressing the very highest respect for law. - Martin Luther King Jr [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] [-- Attachment #2: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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".
next prev parent reply other threads:[~2023-05-06 15:08 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-04-16 16:48 [FFmpeg-devel] [PATCH 01/11] avcodec/adpcm: Fix integer overflow in intermediate in ADPCM_XMD Michael Niedermayer 2023-04-16 16:48 ` [FFmpeg-devel] [PATCH 02/11] avcodec/pngdec: remove AVFrame argument from decode_iccp_chunk() Michael Niedermayer 2023-04-16 16:48 ` [FFmpeg-devel] [PATCH 03/11] avcodec/pngdec: Do not pass AVFrame into global header decode Michael Niedermayer 2023-04-16 16:48 ` [FFmpeg-devel] [PATCH 04/11] avcodec/exr: Cleanup befor return Michael Niedermayer 2023-04-16 16:48 ` [FFmpeg-devel] [PATCH 05/11] avcodec/flacdec: Fix signed integre overflow Michael Niedermayer 2023-05-05 22:36 ` James Almer 2023-05-06 15:08 ` Michael Niedermayer [this message] 2023-05-06 15:18 ` James Almer 2023-04-16 16:48 ` [FFmpeg-devel] [PATCH 06/11] avcodec/utils: the IFF_ILBM implementation assumes that there are a multiple of 16 allocated Michael Niedermayer 2023-04-16 16:48 ` [FFmpeg-devel] [PATCH 07/11] avcodec/sonic: Fix two undefined integer overflows Michael Niedermayer 2023-04-16 16:48 ` [FFmpeg-devel] [PATCH 08/11] avcodec/tak: Check remaining bits in ff_tak_decode_frame_header() Michael Niedermayer 2023-04-16 16:48 ` [FFmpeg-devel] [PATCH 09/11] avcodec/tiff: add a zero DNG_LINEARIZATION_TABLE check Michael Niedermayer 2023-04-16 16:48 ` [FFmpeg-devel] [PATCH 10/11] avcodec/dpcm: fix undefined interger overflow in wady Michael Niedermayer 2023-04-16 16:48 ` [FFmpeg-devel] [PATCH 11/11] avcodec/wavarc: Check order before using it to write the list Michael Niedermayer 2023-04-30 20:04 ` Michael Niedermayer 2023-04-17 7:04 ` [FFmpeg-devel] [PATCH 01/11] avcodec/adpcm: Fix integer overflow in intermediate in ADPCM_XMD Paul B Mahol 2023-04-17 22:45 ` Michael Niedermayer 2023-05-05 22:15 ` Michael Niedermayer 2023-05-05 22:24 ` Paul B Mahol 2023-05-05 22:31 ` Michael Niedermayer 2023-04-17 7:27 ` Paul B Mahol 2023-04-17 11:42 ` Michael Niedermayer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230506150813.GD4538@pb2 \ --to=michael@niedermayer.cc \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git