From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 1857E4DCB8 for ; Mon, 2 Feb 2026 19:24:51 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'LCTX8qnPZ2u70UwmXOMl9OxTSoiq1NOjmL/Qi5L5bbA=', expected b'PuMpzh3xGPp58R8E4HfZJgS3Ap/wjK9f7Yebf1sCHOk=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1770060283; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=LCTX8qnPZ2u70UwmXOMl9OxTSoiq1NOjmL/Qi5L5bbA=; b=ppFJHkPSyg5lXWPuEK1Bxg6aCuiwZglpvbCOU0Tw/UY+VdF7Ax/ZFx/zcoS+NdduDHhO4 b7TLE18+ufl7Vr51CXtXoE/OvlepYwNADLbC8St0COjffH8AOqC42+5muW7Bk18IiL8QVI6 8f7qsn3vht+zmY5rAwpdZakZLy7HQdLGcp+3FMP/cxlMUvyXlwqJsb/urBa4kgFb0KMEn+D oKJQTF9q8n1gORuKrDdEPzQKVkuwaycZaz6KGcnSy/fIxWOG12/hkYZr196helg0WvNWQLf t6ZdSpdPHaDaDGU+glrxyPrpfzDViGTlKfHSuMMVydfroN0c/byHx3Jx1KDA== Received: from [172.20.0.4] (unknown [172.20.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 96CFF690F8C; Mon, 2 Feb 2026 21:24:43 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1770060265; b=Jl2oXxOQm5jL8IyknHBt/mA8cLycWn4O+Pr5RtkIe7l9uvvu4Tgai67B9jmqKSm2zASpa pqjD/p1ZHIUHa2RqQMle+lMufqmVm6TacDnzwXud1c6qSkZcwLiq5vr44aNN+pelAfbiQUe 9iITb6udSSaiGPg5E8dY9Q7QtqAs9c75091CPXwIkBgF8/ae5EHRWiXjHT6oVQvtBEioOFV DBMVgdBu+t8fJr/wJcYIK35Qq5R6TPvv1E56YkAFjuAuKgZeTFp5jAOCwf2Sv8AxrcUCDUF arxnUmGoKjI8RYd7KqKVVLA5ZLl9ZOdzxdvKvG/rZwDjUHKZtN7cr4EZ660g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1770060265; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=R2NkSG//Vgo6WOTUsvHPyYt4Mq0okrajZajHGvqyKrI=; b=R7H81rYhCrH6F6LopzOlp9LwUALOyLvXL3VnBeDrelmCo6HqyVXt5j1sItW8LHWwhlDXu q6zYvBmDsECNJawpNM8m/lIAAeP/FShQ2wnZs/SWpXY5naUz4diGbnjalhd8V6M3EAwqf9o /Jg/IYSIYK5D0d/r8z47++mDwaEst2J3J+qoiE/TngBygStNXmMZ8+nmgnuyzkvl21ywnO2 IJuRsUcPxeAmpCtQ5T0O2Y4K1HqkSLehAQabP8w0F2Ahw2IrvBzsaBmXd9TcBRaGHMuiNzI fEU4I4s/7HvnnsPqinyM+lPHrekbeALg9YjLePilA5Vk1b+GEDoMH3siA5Og== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1770060256; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=PuMpzh3xGPp58R8E4HfZJgS3Ap/wjK9f7Yebf1sCHOk=; b=4eOYrUp/l96F6OblLb7pXOkRFFr/wKhLqoPWCrGq1q6o90ElsJHprIEqG2phl8pSe91eG aJnFACRR/CUHTwZBSS+kXb9QNu+nVbPajLma37khqgVjIpGWWS6eu+KpfkJAELCzr59i7xE N8HouXOgaYwb/AuIF05emvp6FNdNY3/9J6WZ7S9y9NYDq7MIOu+7e4Jkff2fpJ2Y5VIzU4E AOCz7Ov9jMVXXUFMl9K/Lqt1bcYc7+vPfMeC1GBWvuHaMocGtpe8p7n8UATJdHZ44yM/5/f pwqaVBwVEKgoxDFm8G3Q06Kj8i05K6eN0j5CRhWpzVPnmI7TCUUlui+yQI3w== Received: from c8d966988b92 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 9B58F68F7B8 for ; Mon, 2 Feb 2026 21:24:16 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Mon, 02 Feb 2026 19:24:16 -0000 Message-ID: <177006025674.25.3629336070323473091@4457048688e7> Message-ID-Hash: KNAOONVTVAUEFLP3DWKZ2TO55O4YFCSH X-Message-ID-Hash: KNAOONVTVAUEFLP3DWKZ2TO55O4YFCSH X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] avcodec/opus/enc: fix overlap buffer seed for first CELT frame (PR #21629) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: ruikai via ffmpeg-devel Cc: ruikai Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21629 opened by ruikai URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21629 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21629.patch The overlap seed copy in celt_frame_setup_input() used cur->nb_samples as the copy length, which can be 960 with the default opus_delay. This overran the 120 sample overlap buffer and scribbled into samples[]. Clamp the copy to CELT_OVERLAP, copy the tail of the previous frame (the last 120 samples), and zero pad any remainder when the frame is shorter than the overlap size. This prevents the OOB write. >>From 6f52fab4e2da9643d8d4ea0932b48ceb061feea6 Mon Sep 17 00:00:00 2001 From: Ruikai Peng Date: Mon, 2 Feb 2026 14:15:38 -0500 Subject: [PATCH] avcodec/opus/enc: fix overlap buffer seed for first CELT frame The overlap seed copy in celt_frame_setup_input() used cur->nb_samples as the copy length, which can be 960 with the default opus_delay. This overran the 120 sample overlap buffer and scribbled into samples[]. Clamp the copy to CELT_OVERLAP, copy the tail of the previous frame (the last 120 samples), and zero pad any remainder when the frame is shorter than the overlap size. This prevents the OOB write. --- libavcodec/opus/enc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/opus/enc.c b/libavcodec/opus/enc.c index 65e6a09575..462c7d6d77 100644 --- a/libavcodec/opus/enc.c +++ b/libavcodec/opus/enc.c @@ -132,7 +132,13 @@ static void celt_frame_setup_input(OpusEncContext *s, CeltFrame *f) CeltBlock *b = &f->block[ch]; const void *input = cur->extended_data[ch]; size_t bps = av_get_bytes_per_sample(cur->format); - memcpy(b->overlap, input, bps*cur->nb_samples); + const int overlap_len = FFMIN(cur->nb_samples, CELT_OVERLAP); + const size_t overlap_off = (cur->nb_samples - overlap_len) * bps; + memcpy(b->overlap, (const uint8_t *)input + overlap_off, + bps * overlap_len); + if (overlap_len < CELT_OVERLAP) + memset(b->overlap + overlap_len, 0, + (CELT_OVERLAP - overlap_len) * sizeof(*b->overlap)); } av_frame_free(&cur); -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org