1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-30 02:05:13 +01:00

Verify sv4/sc4 sizes when loading them

This commit is contained in:
Michał Janiszewski
2016-09-01 06:59:12 +00:00
committed by Gymnasiast
parent 355b33ba94
commit f3fe28e722
3 changed files with 9 additions and 9 deletions

View File

@@ -262,20 +262,20 @@ size_t sawyercoding_write_chunk_buffer(uint8 *dst_file, uint8* buffer, sawyercod
return chunkHeader.length + sizeof(sawyercoding_chunk_header);
}
size_t sawyercoding_decode_sv4(const uint8 *src, uint8 *dst, size_t length)
size_t sawyercoding_decode_sv4(const uint8 *src, uint8 *dst, size_t length, size_t bufferLength)
{
// (0 to length - 4): RLE chunk
// (length - 4 to length): checksum
return decode_chunk_rle(src, dst, length - 4);
return decode_chunk_rle_with_size(src, dst, length - 4, bufferLength);
}
size_t sawyercoding_decode_sc4(const uint8 *src, uint8 *dst, size_t length)
size_t sawyercoding_decode_sc4(const uint8 *src, uint8 *dst, size_t length, size_t bufferLength)
{
size_t decodedLength, i;
uint32 *code;
// Uncompress
decodedLength = decode_chunk_rle(src, dst, length - 4);
decodedLength = decode_chunk_rle_with_size(src, dst, length - 4, bufferLength);
// Decode
for (i = 0x60018; i <= min(decodedLength - 1, 0x1F8353); i++)