Fixed: Make sure chunk data is at least 5 bytes long for the chunk header.

This commit is contained in:
David Vierra 2012-11-26 02:10:39 -10:00
parent d1f000393c
commit 603e41283f

View File

@ -181,7 +181,9 @@ class MCRegionFile(object):
with self.file as f:
f.seek(sectorStart * self.SECTOR_BYTES)
data = f.read(numSectors * self.SECTOR_BYTES)
assert(len(data) > 0)
if len(data) < 5:
raise RegionMalformed, "Chunk data is only %d bytes long (expected 5)" % len(data)
# log.debug("REGION LOAD {0},{1} sector {2}".format(cx, cz, sectorStart))
length = struct.unpack_from(">I", data)[0]