aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2024-05-23 01:25:50 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2024-06-01 18:01:05 +0200
commit6f52b64bcc345842a88a40ddf3873559f1160e34 (patch)
tree74ae3f0c3629e8e46fcf410383db4af0516f859a /libavdevice
parenteed0a1d3d4524e1e87aca0e75e4bec09833f76f4 (diff)
downloadffmpeg-6f52b64bcc345842a88a40ddf3873559f1160e34.tar.gz
avdevice/pulse_audio_enc: Use av_rescale() to avoid integer overflow
Fixes: CID1503075 Unintentional integer overflow Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/pulse_audio_enc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c
index 3e2cc91f69..80136d1e20 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",