Fix stream descrambling in lrf2lrs

This commit is contained in:
Kovid Goyal 2009-04-02 10:07:19 -07:00
parent e13c15f8e6
commit ba816d3efc

View File

@ -162,9 +162,13 @@ class LRFStream(LRFObject):
self.stream = stream.read(self.stream_size)
if self.stream_flags & 0x200 !=0:
l = len(self.stream);
key = l % self._scramble_key + 0xF;
key = self._scramble_key&0xFF
if key != 0 and key <= 0xF0:
key = l % key + 0xF
else:
key = 0
if l > 0x400 and (isinstance(self, ImageStream) or isinstance(self, Font) or isinstance(self, SoundStream)):
l = 0x400;
l = 0x400
self.stream = self.descramble_buffer(self.stream, l, key)
if self.stream_flags & 0x100 !=0:
decomp_size = struct.unpack("<I", self.stream[:4])[0]