From 774e53bb132461d8d5ebefec1162e29ec0ebc63d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 1 Jan 2020 16:07:03 +1100 Subject: [PATCH] Raise an error for an invalid number of bands in FPX image https://github.com/python-pillow/Pillow/commit/774e53bb132461d8d5ebefec1162e29ec0ebc63d --- src/PIL/FpxImagePlugin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PIL/FpxImagePlugin.py b/src/PIL/FpxImagePlugin.py index 9f284fd..5f409c8 100644 --- a/src/PIL/FpxImagePlugin.py +++ b/src/PIL/FpxImagePlugin.py @@ -101,7 +101,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) -- 2.27.0