mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 13:46:57 +03:00
Add token limit
This commit is contained in:
parent
d2ad27d70a
commit
4dbe244e42
|
@ -87,6 +87,8 @@ class PpmImageFile(ImageFile.ImageFile):
|
||||||
if c in B_WHITESPACE: # token ended
|
if c in B_WHITESPACE: # token ended
|
||||||
break
|
break
|
||||||
token += c
|
token += c
|
||||||
|
if len(token) > 9:
|
||||||
|
raise ValueError(f"Token too long: {token}")
|
||||||
return token
|
return token
|
||||||
|
|
||||||
def _open(self):
|
def _open(self):
|
||||||
|
@ -109,8 +111,9 @@ class PpmImageFile(ImageFile.ImageFile):
|
||||||
self.mode = rawmode = mode
|
self.mode = rawmode = mode
|
||||||
|
|
||||||
for ix in range(3):
|
for ix in range(3):
|
||||||
|
token = self._read_token()
|
||||||
try: # check token sanity
|
try: # check token sanity
|
||||||
token = int(self._read_token())
|
token = int(token)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise SyntaxError("Non-decimal-ASCII found in header")
|
raise SyntaxError("Non-decimal-ASCII found in header")
|
||||||
if ix == 0: # token is the x size
|
if ix == 0: # token is the x size
|
||||||
|
|
Loading…
Reference in New Issue
Block a user