e773f2
From 8ad7b436649c424e22689a8a874c1b0cd7c1c0fc Mon Sep 17 00:00:00 2001
e773f2
From: Lumir Balhar <lbalhar@redhat.com>
e773f2
Date: Mon, 14 Jun 2021 09:22:45 +0200
e773f2
Subject: [PATCH 3/5] CVE-2021-28677
e773f2
e773f2
---
e773f2
 src/PIL/EpsImagePlugin.py | 8 ++++----
e773f2
 1 file changed, 4 insertions(+), 4 deletions(-)
e773f2
e773f2
diff --git a/src/PIL/EpsImagePlugin.py b/src/PIL/EpsImagePlugin.py
e773f2
index b503487..5f5af15 100644
e773f2
--- a/src/PIL/EpsImagePlugin.py
e773f2
+++ b/src/PIL/EpsImagePlugin.py
e773f2
@@ -167,12 +167,12 @@ class PSFile(object):
e773f2
         self.fp.seek(offset, whence)
e773f2
 
e773f2
     def readline(self):
e773f2
-        s = self.char or b""
e773f2
+        s = [self.char or b""]
e773f2
         self.char = None
e773f2
 
e773f2
         c = self.fp.read(1)
e773f2
-        while c not in b"\r\n":
e773f2
-            s = s + c
e773f2
+        while (c not in b"\r\n") and len(c):
e773f2
+            s.append(c)
e773f2
             c = self.fp.read(1)
e773f2
 
e773f2
         self.char = self.fp.read(1)
e773f2
@@ -180,7 +180,7 @@ class PSFile(object):
e773f2
         if self.char in b"\r\n":
e773f2
             self.char = None
e773f2
 
e773f2
-        return s.decode('latin-1')
e773f2
+        return b"".join(s).decode("latin-1")
e773f2
 
e773f2
 
e773f2
 def _accept(prefix):
e773f2
-- 
e773f2
2.31.1
e773f2