mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Input: Fix an infinite loop while trying to unzip a damaged EPUB file. Fixes #1086917 (Load never terminates epub file is truncated)
This commit is contained in:
parent
3e48983a9c
commit
7633b69c8d
@ -152,6 +152,8 @@ def copy_compressed_file(src, size, dest):
|
|||||||
amt = min(size, 20*1024)
|
amt = min(size, 20*1024)
|
||||||
while read < size:
|
while read < size:
|
||||||
raw = src.read(min(size-read, amt))
|
raw = src.read(min(size-read, amt))
|
||||||
|
if not raw and read < size:
|
||||||
|
raise ValueError('Invalid ZIP file, local header is damaged')
|
||||||
read += len(raw)
|
read += len(raw)
|
||||||
dest.write(d.decompress(raw, 200*1024))
|
dest.write(d.decompress(raw, 200*1024))
|
||||||
count = 0
|
count = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user