41 lines
1.6 KiB
Diff
41 lines
1.6 KiB
Diff
From 1eff62205ebe9d42a9417955d2955591be69c9bb Mon Sep 17 00:00:00 2001
|
|
From: Eric Soroos <eric-github@soroos.net>
|
|
Date: Thu, 17 Dec 2020 00:17:53 +0100
|
|
Subject: [PATCH] Fix for CVE CVE-2020-35655 - Read Overflow in PCX Decoding.
|
|
commit 2f409261eb1228e166868f8f0b5da5cda52e55bf upstream
|
|
* Don't trust the image to specify a buffer size
|
|
Conflict:NA
|
|
Reference:https://github.com/python-pillow/Pillow/commit/2f409261eb1228e166868f8f0b5da5cda52e55bf
|
|
---
|
|
src/PIL/PcxImagePlugin.py | 9 +++++++--
|
|
1 file changed, 7 insertions(+), 2 deletions(-)
|
|
diff --git a/src/PIL/PcxImagePlugin.py b/src/PIL/PcxImagePlugin.py
|
|
index daa58b3..82aa3bb 100644
|
|
--- a/src/PIL/PcxImagePlugin.py
|
|
+++ b/src/PIL/PcxImagePlugin.py
|
|
@@ -63,9 +63,9 @@ class PcxImageFile(ImageFile.ImageFile):
|
|
version = i8(s[1])
|
|
bits = i8(s[3])
|
|
planes = i8(s[65])
|
|
- stride = i16(s, 66)
|
|
+ ignored_stride = i16(s, 66)
|
|
logger.debug("PCX version %s, bits %s, planes %s, stride %s",
|
|
- version, bits, planes, stride)
|
|
+ version, bits, planes, ignored_stride)
|
|
|
|
self.info["dpi"] = i16(s, 12), i16(s, 14)
|
|
|
|
@@ -102,6 +102,11 @@ class PcxImageFile(ImageFile.ImageFile):
|
|
self.mode = mode
|
|
self._size = bbox[2]-bbox[0], bbox[3]-bbox[1]
|
|
|
|
+ # don't trust the passed in stride. Calculate for ourselves.
|
|
+ # CVE-2020-35655
|
|
+ stride = (self._size[0] * bits + 7) // 8
|
|
+ stride += stride % 2
|
|
+
|
|
bbox = (0, 0) + self.size
|
|
logger.debug("size: %sx%s", *self.size)
|
|
|
|
--
|
|
2.23.0
|