summaryrefslogtreecommitdiff
path: root/libavcodec/mlpdec.c
diff options
context:
space:
mode:
authorRamiro Polla <ramiro.polla@gmail.com>2009-04-21 22:12:30 +0000
committerRamiro Polla <ramiro.polla@gmail.com>2009-04-21 22:12:30 +0000
commit868170c4da283626973ec97a40d28411cb7fbbdf (patch)
tree441468f83c7b2903b0f9c9ea29f3b07caf7091f5 /libavcodec/mlpdec.c
parent46958efe97b53ee56725d2f03555e06dbead5e30 (diff)
mlpdec: Validate max_channel and max_matrix_channel.
Originally committed as revision 18649 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mlpdec.c')
-rw-r--r--libavcodec/mlpdec.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 493296098a..540d2ed833 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -335,6 +335,9 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
uint8_t checksum;
uint8_t lossless_check;
int start_count = get_bits_count(gbp);
+ const int max_matrix_channel = m->avctx->codec_id == CODEC_ID_MLP
+ ? MAX_MATRIX_CHANNEL_MLP
+ : MAX_MATRIX_CHANNEL_TRUEHD;
sync_word = get_bits(gbp, 13);
s->noise_type = get_bits1(gbp);
@@ -352,6 +355,19 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
s->max_channel = get_bits(gbp, 4);
s->max_matrix_channel = get_bits(gbp, 4);
+ if (s->max_matrix_channel > max_matrix_channel) {
+ av_log(m->avctx, AV_LOG_ERROR,
+ "Max matrix channel cannot be greater than %d.\n",
+ max_matrix_channel);
+ return -1;
+ }
+
+ if (s->max_channel != s->max_matrix_channel) {
+ av_log(m->avctx, AV_LOG_ERROR,
+ "Max channel must be equal max matrix channel.\n");
+ return -1;
+ }
+
if (s->min_channel > s->max_channel) {
av_log(m->avctx, AV_LOG_ERROR,
"Substream min channel cannot be greater than max channel.\n");