From: "Kovacs, Zsolt via ffmpeg-devel" <ffmpeg-devel@ffmpeg.org> To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org> Cc: "Kovacs, Zsolt" <Zsolt.Kovacs@verint.com> Subject: [FFmpeg-devel] [PATCH] libavcodec/g723_1enc: Fix crash Date: Fri, 3 Oct 2025 15:49:36 +0000 Message-ID: <PA4PR01MB90448C77A0D0242D52AF893CF4E4A@PA4PR01MB9044.eurprd01.prod.exchangelabs.com> (raw) [-- Attachment #1: Type: text/plain, Size: 2170 bytes --] Hi All, We had crashes in prod while compressing audio with G.723.1 using ffmpeg as a library. The callstack was: fcb_search, line 1027 ff_encode_encode_cb, line 253 encode_simple_internal, line 339 avcodec_send_frame, line 530 After debugging the issue I found that the crash is caused by FCBParam optim; being uninitialized in fcb_search(). The context of fcb_search(), line 1027 in libavcodec\g723_1enc.c: /* Reconstruct the excitation */ memset(buf, 0, sizeof(int16_t) * SUBFRAME_LEN); for (i = 0; i < pulse_cnt; i++) buf[optim.pulse_pos[i]] = optim.pulse_sign[i]; The last line is 1027, the crash is caused by out of bounds indexing buf with the values in optim.pulse_pos (pulse_cnt is either 5 or 6, and the size of FCBParam::pulse_sign and pulse_pos is PULSE_MAX (6)). The local variable optim is not initialized in fcb_search(). In get_fcb_param() it's assigned at the end of the function in the /* Minimize */ part, but only if (err < optim->min_err), where optim.min_err = 1 << 30;. err is calculated above that in the /* Compute square of error */ part, by clamping a 64 bit int to 32 bits, so it can easily be larger than 1 << 30. If this happens in all the iterations in get_fcb_param(), then optim is not initialized, and buf is indexed by an uninitialized variable, which caused the crashes. The fix is to initialize optim in fcb_search(). After we applied the patch to ffmpeg, the compressions did not crash anymore. Note: this only fixes the crash by ensuring the indices are in the valid range, it doesn't make them correct. Thanks, Zsolt This electronic message may contain proprietary and confidential information of Verint Systems Inc., its affiliates and/or subsidiaries. The information is intended to be for the use of the individual(s) or entity(ies) named above. If you are not the intended recipient (or authorized to receive this e-mail for the intended recipient), you may not use, copy, disclose or distribute to anyone this message or any information contained in this message. If you have received this electronic message in error, please notify us by replying to this e-mail. [-- Attachment #2: 0001-libavcodec-g723_1enc-fix-crash.patch --] [-- Type: application/octet-stream, Size: 873 bytes --] [-- Attachment #3: Type: text/plain, Size: 163 bytes --] _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
next reply other threads:[~2025-10-03 15:50 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-10-03 15:49 Kovacs, Zsolt via ffmpeg-devel [this message] 2025-10-07 0:26 ` [FFmpeg-devel] " Michael Niedermayer via ffmpeg-devel
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=PA4PR01MB90448C77A0D0242D52AF893CF4E4A@PA4PR01MB9044.eurprd01.prod.exchangelabs.com \ --to=ffmpeg-devel@ffmpeg.org \ --cc=Zsolt.Kovacs@verint.com \ /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 http://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/ http://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