diff options
author | Mark Harris <mark.hsj@gmail.com> | 2018-07-21 21:10:17 -0700 |
---|---|---|
committer | Mark Harris <mark.hsj@gmail.com> | 2018-07-21 21:36:34 -0700 |
commit | 1827db6a601e02729475c4618500f49f8b0cbefa (patch) | |
tree | f6cd3ed929a12b117e9766b314de108e95a00ad5 | |
parent | 01b035f8ba4f48e9e1ad9f9407f77ce9a7e4aa44 (diff) | |
download | opus-1827db6a601e02729475c4618500f49f8b0cbefa.tar.gz |
Validate multistream/projection decoder frame_size
-rw-r--r-- | src/opus_multistream_decoder.c | 5 | ||||
-rw-r--r-- | tests/test_opus_api.c | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/opus_multistream_decoder.c b/src/opus_multistream_decoder.c index f767ea0d..e0bd4c66 100644 --- a/src/opus_multistream_decoder.c +++ b/src/opus_multistream_decoder.c @@ -201,6 +201,11 @@ int opus_multistream_decode_native( ALLOC_STACK; VALIDATE_MS_DECODER(st); + if (frame_size <= 0) + { + RESTORE_STACK; + return OPUS_BAD_ARG; + } /* Limit frame_size to avoid excessive stack allocations. */ MUST_SUCCEED(opus_multistream_decoder_ctl(st, OPUS_GET_SAMPLE_RATE(&Fs))); frame_size = IMIN(frame_size, Fs/25*3); diff --git a/tests/test_opus_api.c b/tests/test_opus_api.c index 43c6d143..fb385c63 100644 --- a/tests/test_opus_api.c +++ b/tests/test_opus_api.c @@ -653,6 +653,8 @@ opus_int32 test_msdec_api(void) packet[1]=packet[2]=0; if(opus_multistream_decode(dec, packet, -1, sbuf, 960, 0)!=OPUS_BAD_ARG){printf("%d\n",opus_multistream_decode(dec, packet, -1, sbuf, 960, 0));test_failed();} cfgs++; + if(opus_multistream_decode(dec, packet, 3, sbuf, -960, 0)!=OPUS_BAD_ARG)test_failed(); + cfgs++; if(opus_multistream_decode(dec, packet, 3, sbuf, 60, 0)!=OPUS_BUFFER_TOO_SMALL)test_failed(); cfgs++; if(opus_multistream_decode(dec, packet, 3, sbuf, 480, 0)!=OPUS_BUFFER_TOO_SMALL)test_failed(); |