diff mbox series

[FFmpeg-devel,3/3] avcodec/speexdec: Avoid violating the vector_fmul_scalar() API

Message ID 20211130195935.29259-3-michael@niedermayer.cc
State Accepted
Commit 8e96410e1b8360b6544b74836f3d6971e8ab2fc1
Headers show
Series [FFmpeg-devel,1/3] tools/target_dec_fuzzer: Adjust DXA threshold
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Michael Niedermayer Nov. 30, 2021, 7:59 p.m. UTC
Fixes: out of array access
Fixes: 40054/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-6713285764841472

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/speexdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Dec. 16, 2021, 9:29 p.m. UTC | #1
On Tue, Nov 30, 2021 at 08:59:35PM +0100, Michael Niedermayer wrote:
> Fixes: out of array access
> Fixes: 40054/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-6713285764841472
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/speexdec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
index e263d4c48ce..1c33607db27 100644
--- a/libavcodec/speexdec.c
+++ b/libavcodec/speexdec.c
@@ -1545,7 +1545,7 @@  static int speex_decode_frame(AVCodecContext *avctx, void *data,
     if ((ret = init_get_bits8(&s->gb, avpkt->data, buf_size)) < 0)
         return ret;
 
-    frame->nb_samples = s->frame_size * s->frames_per_packet;
+    frame->nb_samples = FFALIGN(s->frame_size * s->frames_per_packet, 4);
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
@@ -1560,6 +1560,7 @@  static int speex_decode_frame(AVCodecContext *avctx, void *data,
 
     dst = (float *)frame->extended_data[0];
     s->fdsp->vector_fmul_scalar(dst, dst, scale, frame->nb_samples * frame->channels);
+    frame->nb_samples = s->frame_size * s->frames_per_packet;
 
     *got_frame_ptr = 1;