1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Some sanity checks for BinaryBlob header data

This commit is contained in:
Ethan Lee 2020-06-14 22:39:06 -04:00
parent 33fd589616
commit 06a71bab18

View file

@ -98,14 +98,27 @@ bool binaryBlob::unPackBinary(const char* name)
for (int i = 0; i < 128; i += 1)
{
if (m_headers[i].valid)
/* Name can be stupid, just needs to be terminated */
m_headers[i].name[47] = '\0';
if (m_headers[i].valid & ~0x1)
{
continue; /* Must be EXACTLY 1 */
}
if ((offset + m_headers[i].size) > size)
{
continue; /* Bogus size value */
}
PHYSFS_seek(handle, offset);
m_memblocks[i] = (char*) malloc(m_headers[i].size);
if (m_memblocks[i] == NULL)
{
exit(1); /* Oh god we're out of memory, just bail */
}
PHYSFS_readBytes(handle, m_memblocks[i], m_headers[i].size);
offset += m_headers[i].size;
}
}
PHYSFS_close(handle);
printf("The complete reloaded file size: %lli\n", size);