Skip to content

Commit

Permalink
Merge pull request #178 from psd-tools/v1.8.36
Browse files Browse the repository at this point in the history
v1.8.36
  • Loading branch information
kyamagu committed Jan 23, 2020
2 parents 64197a1 + 70fca42 commit 0523831
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
1.8.35 (2019-12-26)
-------------------

- [psd] add safeguard for malformed global layer mask info parser.

1.8.35 (2019-12-26)
-------------------

- [api] remove duplicate `has_mask()` definition.
- [composer] fix empty effects check.

Expand Down
11 changes: 10 additions & 1 deletion src/psd_tools/psd/layer_and_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def read(cls, fp, encoding='macroman', version=1):
@classmethod
def _read_body(cls, fp, end_pos, encoding, version):
layer_info = LayerInfo.read(fp, encoding, version)

global_layer_mask_info = None
if is_readable(fp) and fp.tell() < end_pos:
if is_readable(fp, 17) and fp.tell() < end_pos:
global_layer_mask_info = GlobalLayerMaskInfo.read(fp)

tagged_blocks = None
Expand Down Expand Up @@ -929,10 +930,18 @@ class GlobalLayerMaskInfo(BaseElement):

@classmethod
def read(cls, fp):
pos = fp.tell()
data = read_length_block(fp) # fmt?
logger.debug('reading global layer mask info, len=%d' % (len(data)))
if len(data) == 0:
return cls(overlay_color=None)
elif len(data) < 13:
logger.warning(
'global layer mask info is broken, expected 13 bytes but found '
'only %d' % (len(data))
)
fp.seek(pos)
return cls(overlay_color=None)

with io.BytesIO(data) as f:
return cls._read_body(f)
Expand Down
2 changes: 1 addition & 1 deletion src/psd_tools/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.8.35'
__version__ = '1.8.36'

0 comments on commit 0523831

Please sign in to comment.