[FFmpeg-cvslog] avcodec/speexdec: check for sane frame_size values

James Almer git at videolan.org
Fri Feb 16 20:22:09 EET 2024


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Fri Feb 16 11:17:13 2024 -0300| [66b50445cb36cf6adb49c2397362509aedb42c71] | committer: James Almer

avcodec/speexdec: check for sane frame_size values

Regression since ab39cc36c72bb73318bb911acb66873de850a107.

Fixes heap buffer overflows
Fixes ticket #10866

Reported-by: sploitem <sploitem at gmail.com>
Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=66b50445cb36cf6adb49c2397362509aedb42c71
---

 libavcodec/speexdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c
index 51c5834769..4d8052d585 100644
--- a/libavcodec/speexdec.c
+++ b/libavcodec/speexdec.c
@@ -1420,7 +1420,10 @@ static int parse_speex_extradata(AVCodecContext *avctx,
     if (s->nb_channels <= 0 || s->nb_channels > 2)
         return AVERROR_INVALIDDATA;
     s->bitrate = bytestream_get_le32(&buf);
-    s->frame_size = (1 + (s->mode > 0)) * bytestream_get_le32(&buf);
+    s->frame_size = bytestream_get_le32(&buf);
+    if (s->frame_size < NB_FRAME_SIZE << (s->mode > 0))
+        return AVERROR_INVALIDDATA;
+    s->frame_size *= 1 + (s->mode > 0);
     s->vbr = bytestream_get_le32(&buf);
     s->frames_per_packet = bytestream_get_le32(&buf);
     if (s->frames_per_packet <= 0 ||



More information about the ffmpeg-cvslog mailing list