diff options
author | Mark Harris <mark.hsj@gmail.com> | 2014-11-27 19:48:09 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2014-11-27 20:04:14 +0300 |
commit | 25b27a9c167302769db512a9e32c66323bc7904c (patch) | |
tree | 2c0df6c184b180fcf252f94a6389a23e42d04666 /src/opus_multistream_decoder.c | |
parent | d10755e95c49f5ec925e70598877c82ad865a189 (diff) |
multistream: improve arg check
Avoid undefined behavior (signed arithmetic overflow) or
implementation-defined behavior (malloc(0)) on out-of-range arguments,
e.g. opus_multistream_encoder_create(48000, 2, 2147483647, 1, ...)
or opus_multistream_surround_encoder_create(48000, 3, 0, ...).
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
Diffstat (limited to 'src/opus_multistream_decoder.c')
-rw-r--r-- | src/opus_multistream_decoder.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/opus_multistream_decoder.c b/src/opus_multistream_decoder.c index a05fa1e7..b95eaa6e 100644 --- a/src/opus_multistream_decoder.c +++ b/src/opus_multistream_decoder.c @@ -75,7 +75,7 @@ int opus_multistream_decoder_init( char *ptr; if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0)) + (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) return OPUS_BAD_ARG; st->layout.nb_channels = channels; @@ -119,7 +119,7 @@ OpusMSDecoder *opus_multistream_decoder_create( int ret; OpusMSDecoder *st; if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0)) + (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) { if (error) *error = OPUS_BAD_ARG; |