From ff1f89de2da3472d133e2c95bf7c9ad2d88df33d Mon Sep 17 00:00:00 2001
From: Justin Ruggles <justin.ruggles@gmail.com>
Date: Wed, 21 Sep 2011 11:49:33 -0400
Subject: smacker: validate channels and sample format.

---
 libavcodec/smacker.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 20ddc15915..d8a3d7733b 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -606,6 +606,14 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
         av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
         return -1;
     }
+    if (stereo ^ (avctx->channels != 1)) {
+        av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");
+        return AVERROR(EINVAL);
+    }
+    if (bits && avctx->sample_fmt == AV_SAMPLE_FMT_U8) {
+        av_log(avctx, AV_LOG_ERROR, "sample format mismatch\n");
+        return AVERROR(EINVAL);
+    }
 
     memset(vlc, 0, sizeof(VLC) * 4);
     memset(h, 0, sizeof(HuffContext) * 4);
-- 
cgit v1.2.3