[FFmpeg-devel] [PATCH 1/2] avcodec/speexdec: Check frames_per_packet more completely

James Almer jamrial at gmail.com
Fri Oct 15 01:20:38 EEST 2021


On 10/14/2021 7:13 PM, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2105344 * 539033345 cannot be represented in type 'int'
> Fixes: out of array write
> Fixes: 39956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-4766419250708480
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
>   libavcodec/speexdec.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
> index 4c50f54f27b..05f084de2e5 100644
> --- a/libavcodec/speexdec.c
> +++ b/libavcodec/speexdec.c
> @@ -1428,7 +1428,7 @@ static int parse_speex_extradata(AVCodecContext *avctx,
>           return AVERROR_INVALIDDATA;
>       s->vbr = bytestream_get_le32(&buf);
>       s->frames_per_packet = bytestream_get_le32(&buf);
> -    if (s->frames_per_packet <= 0)
> +    if (s->frames_per_packet <= 0 || s->frames_per_packet >= INT32_MAX / s->frame_size)

s->frames_per_packet * s->frame_size is then multiplied by channel count 
(which can be at most 2) for the vector_fmul_scalar() call, so might as 
well check for that here too.

Alternatively, all floatdsp functions could be adapted to take size_t 
buffer lengths.

>           return AVERROR_INVALIDDATA;
>       s->extra_headers = bytestream_get_le32(&buf);
>   
> 



More information about the ffmpeg-devel mailing list