fix sparse get size()

This commit is contained in:
bongbui321 2024-03-02 01:55:00 -05:00
parent 31892ae1b2
commit fbf9157df5

View file

@ -81,20 +81,21 @@ class QCSparse(metaclass=LogBase):
chunk_sz = header[2] chunk_sz = header[2]
total_sz = header[3] total_sz = header[3]
data_sz = total_sz - 12 data_sz = total_sz - 12
self.rf.seek(self.rf.tell + data_sz)
if chunk_type == 0xCAC1: if chunk_type == 0xCAC1:
if data_sz != (chunk_sz * self.blk_sz): if data_sz != (chunk_sz * self.blk_sz):
self.error( self.error(
"Raw chunk input size (%u) does not match output size (%u)" % (data_sz, chunk_sz * self.blk_sz)) "Raw chunk input size (%u) does not match output size (%u)" % (data_sz, chunk_sz * self.blk_sz))
return -1 return -1
else: else:
self.rf.seek(self.rf.tell() + chunk_sz * self.blk_sz)
return chunk_sz * self.blk_sz return chunk_sz * self.blk_sz
elif chunk_type == 0xCAC2: elif chunk_type == 0xCAC2:
if data_sz != 4: if data_sz != 4:
self.error("Fill chunk should have 4 bytes of fill, but this has %u" % data_sz) self.error("Fill chunk should have 4 bytes of fill, but this has %u" % data_sz)
return -1 return -1
else: else:
return chunk_sz * self.blk_sz // 4 return chunk_sz * self.blk_sz
elif chunk_type == 0xCAC3: elif chunk_type == 0xCAC3:
return chunk_sz * self.blk_sz return chunk_sz * self.blk_sz
elif chunk_type == 0xCAC4: elif chunk_type == 0xCAC4:
@ -102,7 +103,6 @@ class QCSparse(metaclass=LogBase):
self.error("CRC32 chunk should have 4 bytes of CRC, but this has %u" % data_sz) self.error("CRC32 chunk should have 4 bytes of CRC, but this has %u" % data_sz)
return -1 return -1
else: else:
self.rf.seek(self.rf.tell() + 4)
return 0 return 0
else: else:
self.debug("Unknown chunk type 0x%04X" % chunk_type) self.debug("Unknown chunk type 0x%04X" % chunk_type)