mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-06-04 22:50:24 +00:00
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:
parent
8e8d570e78
commit
d030db25ab
1 changed files with 3 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue