Skip to content

Commit

Permalink
Merge pull request #64 from WinMin/master
Browse files Browse the repository at this point in the history
add "totBytes check, fix #62
  • Loading branch information
kn007 authored Jun 22, 2020
2 parents 21feb28 + 42b5315 commit d216599
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions silk/test/Decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ 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 ];
SKP_memmove( nBytesPerPacket, &nBytesPerPacket[ 1 ], MAX_LBRR_DELAY * sizeof( SKP_int16 ) );
Expand Down Expand Up @@ -453,6 +459,15 @@ 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 ];
SKP_memmove( nBytesPerPacket, &nBytesPerPacket[ 1 ], MAX_LBRR_DELAY * sizeof( SKP_int16 ) );
Expand Down

0 comments on commit d216599

Please # to comment.