Validate multistream/projection decoder frame_size
authorMark Harris <mark.hsj@gmail.com>
Sun, 22 Jul 2018 04:10:17 +0000 (21:10 -0700)
committerMark Harris <mark.hsj@gmail.com>
Sun, 22 Jul 2018 04:36:34 +0000 (21:36 -0700)
src/opus_multistream_decoder.c
tests/test_opus_api.c

index f767ea0..e0bd4c6 100644 (file)
@@ -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);
index 43c6d14..fb385c6 100644 (file)
@@ -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();