mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix stream descrambling in lrf2lrs
This commit is contained in:
parent
e13c15f8e6
commit
ba816d3efc
@ -162,9 +162,13 @@ class LRFStream(LRFObject):
|
|||||||
self.stream = stream.read(self.stream_size)
|
self.stream = stream.read(self.stream_size)
|
||||||
if self.stream_flags & 0x200 !=0:
|
if self.stream_flags & 0x200 !=0:
|
||||||
l = len(self.stream);
|
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)):
|
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)
|
self.stream = self.descramble_buffer(self.stream, l, key)
|
||||||
if self.stream_flags & 0x100 !=0:
|
if self.stream_flags & 0x100 !=0:
|
||||||
decomp_size = struct.unpack("<I", self.stream[:4])[0]
|
decomp_size = struct.unpack("<I", self.stream[:4])[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user