mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-02 19:03:24 +03:00
Explicitly check if magic number is empty
This commit is contained in:
parent
3426052874
commit
f5b9e2c43a
|
@ -52,7 +52,7 @@ class PpmImageFile(ImageFile.ImageFile):
|
||||||
def _read_magic(self, magic=b""):
|
def _read_magic(self, magic=b""):
|
||||||
while True: # read until next whitespace
|
while True: # read until next whitespace
|
||||||
c = self.fp.read(1)
|
c = self.fp.read(1)
|
||||||
if c in b_whitespace:
|
if not c or c in b_whitespace:
|
||||||
break
|
break
|
||||||
magic += c
|
magic += c
|
||||||
if len(magic) > 6: # exceeded max magic number length
|
if len(magic) > 6: # exceeded max magic number length
|
||||||
|
@ -69,9 +69,9 @@ class PpmImageFile(ImageFile.ImageFile):
|
||||||
if c == b"#": # found comment, ignore it
|
if c == b"#": # found comment, ignore it
|
||||||
_ignore_comment()
|
_ignore_comment()
|
||||||
continue
|
continue
|
||||||
|
if not c:
|
||||||
|
raise ValueError("Reached EOF while reading header")
|
||||||
if c in b_whitespace: # found whitespace, ignore it
|
if c in b_whitespace: # found whitespace, ignore it
|
||||||
if c == b"": # reached EOF
|
|
||||||
raise ValueError("Reached EOF while reading header")
|
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user