summaryrefslogtreecommitdiffstats
path: root/libavdevice
diff options
context:
space:
mode:
authorLukasz Marek <lukasz.m.luki@gmail.com>2013-10-26 01:32:55 +0200
committerNicolas George <george@nsup.org>2013-11-03 10:28:15 +0100
commite56d1a120324fa49a5367cbf22098c5c7eb23f91 (patch)
tree5cf22bc0246aac07ba9f0927de460e031de37794 /libavdevice
parent6ac9afd16e385fc450c58b8a3fb44baa99ea4af9 (diff)
downloadffmpeg-streaming-e56d1a120324fa49a5367cbf22098c5c7eb23f91.zip
ffmpeg-streaming-e56d1a120324fa49a5367cbf22098c5c7eb23f91.tar.gz
lavd/alsa: add stream validation
Don't trust provided streams. Return with error when stream count is not 1 or provided stream is not an audio stream. Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/alsa-audio-enc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c
index 5033a48..83e1d2f 100644
--- a/libavdevice/alsa-audio-enc.c
+++ b/libavdevice/alsa-audio-enc.c
@@ -47,12 +47,17 @@
static av_cold int audio_write_header(AVFormatContext *s1)
{
AlsaData *s = s1->priv_data;
- AVStream *st;
+ AVStream *st = NULL;
unsigned int sample_rate;
enum AVCodecID codec_id;
int res;
+ if (s1->nb_streams != 1 || s1->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
+ av_log(s1, AV_LOG_ERROR, "Only a single audio stream is supported.\n");
+ return AVERROR(EINVAL);
+ }
st = s1->streams[0];
+
sample_rate = st->codec->sample_rate;
codec_id = st->codec->codec_id;
res = ff_alsa_open(s1, SND_PCM_STREAM_PLAYBACK, &sample_rate,
OpenPOWER on IntegriCloud