diff --git a/silk/test/Decoder.c b/silk/test/Decoder.c index 2d33a1a..2fc35a4 100644 --- a/silk/test/Decoder.c +++ b/silk/test/Decoder.c @@ -266,6 +266,11 @@ int main( int argc, char* argv[] ) break; } + if( nBytes > MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES ) { + fprintf( stderr, "\rPacket is too large: %d", nBytes ); + return -1; + } + /* Read payload */ counter = fread( payloadEnd, sizeof( SKP_uint8 ), nBytes, bitInFile ); if( ( SKP_int16 )counter < nBytes ) { @@ -459,14 +464,6 @@ int main( int argc, char* argv[] ) for( i = 0; i < MAX_LBRR_DELAY; i++ ) { totBytes += nBytesPerPacket[ i + 1 ]; } - - /* Check if the received totBytes is valid */ - if (totBytes < 0 || totBytes > sizeof(payload)) - { - - fprintf( stderr, "\rPackets decoded: %d", totPackets ); - return -1; - } SKP_memmove( payload, &payload[ nBytesPerPacket[ 0 ] ], totBytes * sizeof( SKP_uint8 ) ); payloadEnd -= nBytesPerPacket[ 0 ];