summaryrefslogtreecommitdiff
path: root/libavformat/oggparsespeex.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-04-07 17:39:30 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-11-12 10:33:20 -0500
commitd4088efbe22f2e4f8fc10d63bb50835779a702be (patch)
treed17dd7fb0e60597d7e0a3f21a9cbd5ef752315de /libavformat/oggparsespeex.c
parent232e9c4c4bed38d54c9c55efb8ffc2b12d55b427 (diff)
oggparsespeex: validate channel count and set channel layout
Diffstat (limited to 'libavformat/oggparsespeex.c')
-rw-r--r--libavformat/oggparsespeex.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
index 11b50d5905..42480a3a27 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/oggparsespeex.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include "libavutil/bswap.h"
#include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
#include "libavcodec/get_bits.h"
#include "libavcodec/bytestream.h"
#include "avformat.h"
@@ -59,6 +60,12 @@ static int speex_header(AVFormatContext *s, int idx) {
st->codec->sample_rate = AV_RL32(p + 36);
st->codec->channels = AV_RL32(p + 48);
+ if (st->codec->channels < 1 || st->codec->channels > 2) {
+ av_log(s, AV_LOG_ERROR, "invalid channel count. Speex must be mono or stereo.\n");
+ return AVERROR_INVALIDDATA;
+ }
+ st->codec->channel_layout = st->codec->channels == 1 ? AV_CH_LAYOUT_MONO :
+ AV_CH_LAYOUT_STEREO;
spxp->packet_size = AV_RL32(p + 56);
frames_per_packet = AV_RL32(p + 64);