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 E5F2648319 for ; Thu, 23 May 2024 01:18:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5056C68D428; Thu, 23 May 2024 04:18:07 +0300 (EEST) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BC3C768D26B for ; Thu, 23 May 2024 04:18:00 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 8CFF520002 for ; Thu, 23 May 2024 01:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1716427079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=vVAF6IP7ITBS1YSMtV71q+WK6lrXQe9bCzabDbDRVV8=; b=cYRwtdZi4gXhT2nkdeDDZPc/ihbAOiH3izUni3IDl3JhG9vYU2d3VSKc+XMUIqIHZHLtyM GG+smGpjW+Qh1ktLY99vpsurcnU64Tg1/wpwGf1WkcL1vKXUcS/2Hs+Urc7GmmpP4yQo4U fg8e+qepa98Rdn9oKoEpAmcvdXHOhBmr36U56CaVVgqsuaOI26Ud7W5/h7qgsgn/y3IS/j +uP0dbxRCYNKkaD3XeMnSiRBaaDLxGkrmzqe/PZlOEc4Q004z9D0HmVfljt2jKT52AZ7Rm 9bRwW1Y1oF/o1wtvVKh5rAfx8G3V9iurO3fiOA9pDT2jA9Vzr9tAKnpSMDTvIA== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 23 May 2024 03:17:52 +0200 Message-ID: <20240523011758.2434580-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 1/7] avdevice/pulse_audio_enc: Use av_rescale() to avoid integer 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: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Fixes: CID1503075 Unintentional integer overflow Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavdevice/pulse_audio_enc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c index 3e2cc91f697..80136d1e20c 100644 --- a/libavdevice/pulse_audio_enc.c +++ b/libavdevice/pulse_audio_enc.c @@ -471,10 +471,11 @@ static av_cold int pulse_write_header(AVFormatContext *h) s->nonblocking = (h->flags & AVFMT_FLAG_NONBLOCK); if (s->buffer_duration) { - int64_t bytes = s->buffer_duration; - bytes *= st->codecpar->ch_layout.nb_channels * st->codecpar->sample_rate * - av_get_bytes_per_sample(st->codecpar->format); - bytes /= 1000; + int64_t bytes = av_rescale(s->buffer_duration, + st->codecpar->ch_layout.nb_channels * + (int64_t)st->codecpar->sample_rate * + av_get_bytes_per_sample(st->codecpar->format), + 1000); buffer_attributes.tlength = FFMAX(s->buffer_size, av_clip64(bytes, 0, UINT32_MAX - 1)); av_log(s, AV_LOG_DEBUG, "Buffer duration: %ums recalculated into %"PRId64" bytes buffer.\n", -- 2.45.1 _______________________________________________ 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".