diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-12-03 05:40:55 +0300 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-12-03 05:59:13 +0300 |
commit | afcf15b0dbb4b6429be5083e50b296cdca61875e (patch) | |
tree | 788be7d15479a1044fae73604661f550cdfd9885 /libavformat/oggparsespeex.c | |
parent | 90da187f1d334422477886a19eca3c1da29c59a7 (diff) |
avformat/oggparsespeex: Check frames_per_packet and packet_size
The speex specification does not seem to restrict these values, thus
the limits where choosen so as to avoid multiplicative overflow
Fixes undefined behavior
Fixes: 635422.ogg
Found-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/oggparsespeex.c')
-rw-r--r-- | libavformat/oggparsespeex.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c index 2b49150878..27fc99247d 100644 --- a/libavformat/oggparsespeex.c +++ b/libavformat/oggparsespeex.c @@ -82,6 +82,13 @@ static int speex_header(AVFormatContext *s, int idx) { spxp->packet_size = AV_RL32(p + 56); frames_per_packet = AV_RL32(p + 64); + if (spxp->packet_size < 0 || + frames_per_packet < 0 || + spxp->packet_size * (int64_t)frames_per_packet > INT32_MAX / 256) { + av_log(s, AV_LOG_ERROR, "invalid packet_size, frames_per_packet %d %d\n", spxp->packet_size, frames_per_packet); + spxp->packet_size = 0; + return AVERROR_INVALIDDATA; + } if (frames_per_packet) spxp->packet_size *= frames_per_packet; |