CLZSS: Fix bug causing iterator to go out of bounds

Check if 'position' exceeds buffer size.
This commit is contained in:
Kawe Mazidjatari 2023-04-05 22:31:37 +02:00
parent dbe1850ec1
commit e76f5b98c8

View File

@ -329,13 +329,15 @@ unsigned int CLZSS::SafeUncompress( unsigned char *pInput, unsigned char *pOutpu
{
break;
}
unsigned char *pSource = pOutput - position - 1;
if ( totalBytes + count > unBufSize )
if ( position > totalBytes || // out of bounds
totalBytes + count > unBufSize )
{
return 0;
}
unsigned char* pSource = pOutput - position - 1;
for ( int i=0; i<count; i++ )
{
*pOutput++ = *pSource++;