1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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>
This commit is contained in:
Michael Niedermayer 2024-05-23 01:25:50 +02:00
parent eed0a1d3d4
commit 6f52b64bcc
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -471,10 +471,11 @@ static av_cold int pulse_write_header(AVFormatContext *h)
s->nonblocking = (h->flags & AVFMT_FLAG_NONBLOCK); s->nonblocking = (h->flags & AVFMT_FLAG_NONBLOCK);
if (s->buffer_duration) { if (s->buffer_duration) {
int64_t bytes = s->buffer_duration; int64_t bytes = av_rescale(s->buffer_duration,
bytes *= st->codecpar->ch_layout.nb_channels * st->codecpar->sample_rate * st->codecpar->ch_layout.nb_channels *
av_get_bytes_per_sample(st->codecpar->format); (int64_t)st->codecpar->sample_rate *
bytes /= 1000; av_get_bytes_per_sample(st->codecpar->format),
1000);
buffer_attributes.tlength = FFMAX(s->buffer_size, av_clip64(bytes, 0, UINT32_MAX - 1)); buffer_attributes.tlength = FFMAX(s->buffer_size, av_clip64(bytes, 0, UINT32_MAX - 1));
av_log(s, AV_LOG_DEBUG, av_log(s, AV_LOG_DEBUG,
"Buffer duration: %ums recalculated into %"PRId64" bytes buffer.\n", "Buffer duration: %ums recalculated into %"PRId64" bytes buffer.\n",