From cb06bf0dac9581e52ca490a09f498cea0f3ddc49 Mon Sep 17 00:00:00 2001 From: Cllarisy Date: Mon, 30 Sep 2024 18:39:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=89=8D=E5=AF=B9=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E5=90=88=E6=B3=95=E6=80=A7=E6=A3=80?= =?UTF-8?q?=E6=B5=8B,=20=E4=BF=AE=E5=A4=8D=20nBytes=20=E5=A4=A7=E4=BA=8E?= =?UTF-8?q?=20sizeof(payload)=20=E5=AF=BC=E8=87=B4=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=B6=20payload=20=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- silk/test/Decoder.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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 ];