avcodec/dfpwmdec: Check nb_samples

Fixes: integer overflow

Found-by: Dhiraj Mishra <mishra.dhiraj95@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 118bddf0ce)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2026-05-01 21:33:25 +02:00
parent 8e8d570e78
commit d030db25ab
No known key found for this signature in database
GPG key ID: B18E8928B3948D64

View file

@ -101,15 +101,16 @@ static int dfpwm_dec_frame(struct AVCodecContext *ctx, AVFrame *frame,
{
DFPWMState *state = ctx->priv_data;
int ret;
uint64_t nb_samples = packet->size * 8LL / ctx->ch_layout.nb_channels;
if (packet->size * 8LL % ctx->ch_layout.nb_channels)
return AVERROR_PATCHWELCOME;
frame->nb_samples = packet->size * 8LL / ctx->ch_layout.nb_channels;
if (frame->nb_samples <= 0) {
if (nb_samples > INT_MAX || !nb_samples) {
av_log(ctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
return AVERROR_INVALIDDATA;
}
frame->nb_samples = nb_samples;
if ((ret = ff_get_buffer(ctx, frame, 0)) < 0)
return ret;