Skip to content

Commit

Permalink
Merge pull request #458 from girder/guard-tile-range
Browse files Browse the repository at this point in the history
Guard against reading tiff tiles outside of the image.
  • Loading branch information
manthey authored Jun 12, 2020
2 parents 20a606f + 2ca9db3 commit 712ce6d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sources/tiff/large_image_source_tiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False,
sparseFallback=False, **kwargs):
if z < 0:
raise TileSourceException('z layer does not exist')
scale = 2 ** (self.levels - 1 - z)
offsetx = x * self.tileWidth * scale
if not (0 <= offsetx < self.sizeX):
raise TileSourceException('x is outside layer')
offsety = y * self.tileHeight * scale
if not (0 <= offsety < self.sizeY):
raise TileSourceException('y is outside layer')
try:
allowStyle = True
if self._tiffDirectories[z] is None:
Expand Down

0 comments on commit 712ce6d

Please sign in to comment.