mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
CLZSS: Fix bug causing iterator to go out of bounds
Check if 'position' exceeds buffer size.
This commit is contained in:
parent
dbe1850ec1
commit
e76f5b98c8
@ -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++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user