mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Merge pull request #7883 from radarhere/tiff
Raise ValueError if seeking to greater than offset-sized integer in TIFF
This commit is contained in:
		
						commit
						da13358245
					
				
							
								
								
									
										
											BIN
										
									
								
								Tests/images/seek_too_large.tif
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/seek_too_large.tif
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -113,6 +113,10 @@ class TestFileTiff:
 | 
				
			||||||
            outfile = str(tmp_path / "temp.tif")
 | 
					            outfile = str(tmp_path / "temp.tif")
 | 
				
			||||||
            im.save(outfile, save_all=True, append_images=[im], tiffinfo=im.tag_v2)
 | 
					            im.save(outfile, save_all=True, append_images=[im], tiffinfo=im.tag_v2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_seek_too_large(self):
 | 
				
			||||||
 | 
					        with pytest.raises(ValueError, match="Unable to seek to frame"):
 | 
				
			||||||
 | 
					            Image.open("Tests/images/seek_too_large.tif")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_set_legacy_api(self) -> None:
 | 
					    def test_set_legacy_api(self) -> None:
 | 
				
			||||||
        ifd = TiffImagePlugin.ImageFileDirectory_v2()
 | 
					        ifd = TiffImagePlugin.ImageFileDirectory_v2()
 | 
				
			||||||
        with pytest.raises(Exception) as e:
 | 
					        with pytest.raises(Exception) as e:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1167,6 +1167,9 @@ class TiffImageFile(ImageFile.ImageFile):
 | 
				
			||||||
                self.__next,
 | 
					                self.__next,
 | 
				
			||||||
                self.fp.tell(),
 | 
					                self.fp.tell(),
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					            if self.__next >= 2**63:
 | 
				
			||||||
 | 
					                msg = "Unable to seek to frame"
 | 
				
			||||||
 | 
					                raise ValueError(msg)
 | 
				
			||||||
            self.fp.seek(self.__next)
 | 
					            self.fp.seek(self.__next)
 | 
				
			||||||
            self._frame_pos.append(self.__next)
 | 
					            self._frame_pos.append(self.__next)
 | 
				
			||||||
            logger.debug("Loading tags, location: %s", self.fp.tell())
 | 
					            logger.debug("Loading tags, location: %s", self.fp.tell())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user