mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-13 09:15:46 +03:00
Raise an error for an invalid number of bands in FPX image
This commit is contained in:
parent
8892aecfbf
commit
774e53bb13
BIN
Tests/images/input_bw_five_bands.fpx
Normal file
BIN
Tests/images/input_bw_five_bands.fpx
Normal file
Binary file not shown.
|
@ -1,3 +1,5 @@
|
|||
from PIL import Image
|
||||
|
||||
from .helper import PillowTestCase, unittest
|
||||
|
||||
try:
|
||||
|
@ -18,3 +20,7 @@ class TestFileFpx(PillowTestCase):
|
|||
# Test a valid OLE file, but not an FPX file
|
||||
ole_file = "Tests/images/test-ole-file.doc"
|
||||
self.assertRaises(SyntaxError, FpxImagePlugin.FpxImageFile, ole_file)
|
||||
|
||||
def test_fpx_invalid_number_of_bands(self):
|
||||
with self.assertRaisesRegex(IOError, "Invalid number of bands"):
|
||||
Image.open("Tests/images/input_bw_five_bands.fpx")
|
||||
|
|
|
@ -104,7 +104,10 @@ class FpxImageFile(ImageFile.ImageFile):
|
|||
s = prop[0x2000002 | id]
|
||||
|
||||
colors = []
|
||||
for i in range(i32(s, 4)):
|
||||
bands = i32(s, 4)
|
||||
if bands > 4:
|
||||
raise IOError("Invalid number of bands")
|
||||
for i in range(bands):
|
||||
# note: for now, we ignore the "uncalibrated" flag
|
||||
colors.append(i32(s, 8 + i * 4) & 0x7FFFFFFF)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user