Opus_multistream API hardening.
authorGregory Maxwell <greg@xiph.org>
Sat, 14 Jul 2012 19:49:20 +0000 (15:49 -0400)
committerGregory Maxwell <greg@xiph.org>
Sat, 14 Jul 2012 19:50:30 +0000 (15:50 -0400)
src/opus_multistream.c

index 1128c07..5b2519d 100644 (file)
@@ -163,6 +163,10 @@ int opus_multistream_encoder_init(
    int i;
    char *ptr;
 
+   if ((channels>255) || (coupled_streams>streams) ||
+       (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0))
+      return OPUS_BAD_ARG;
+
    st->layout.nb_channels = channels;
    st->layout.nb_streams = streams;
    st->layout.nb_coupled_streams = coupled_streams;
@@ -534,6 +538,10 @@ int opus_multistream_decoder_init(
    int i, ret;
    char *ptr;
 
+   if ((channels>255) || (coupled_streams>streams) ||
+       (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0))
+      return OPUS_BAD_ARG;
+
    st->layout.nb_channels = channels;
    st->layout.nb_streams = streams;
    st->layout.nb_coupled_streams = coupled_streams;