Hi.

The PIL module XVThumbImagePlugin.py has an issue with XVThumb files that do not include #END_OF_COMMENTS (or a comment section at all). I'm not quite sure if the problem is an invalid file (is the comment required?), but we encountered a file like this. Anyway, the result is XVThumbImagePlugin being stuck in an infinite loop. The patch supports files without comments and/or comment sections without #END_OF_COMMENTS.

Attached is a diff against XVThumbImagePlugin.py from PIL version 1.1.6. (I didn't figure out where else to send the diff.)

-Nikolai
--- XVThumbImagePlugin.py 
+++ XVThumbImagePlugin.py 
@@ -44,14 +44,19 @@
         if s != "P7 332":
             raise SyntaxError, "not an XV thumbnail file"
 
+        # Skip to beginning of next line
+        self.fp.readline()
+
         # skip info comments
         while 1:
-            s = string.strip(self.fp.readline())
-            if s == "#END_OF_COMMENTS":
+            s = self.fp.readline()
+            if not s:
+                raise SyntaxError, "Unexpected EOF reading XV thumbnail file"
+            if s[0] != '#':
                 break
 
-        # read header line
-        s = string.split(self.fp.readline())
+        # parse header line (already read)
+        s = string.split(s.strip())
 
         self.mode = "P"
         self.size = int(s[0]), int(s[1])
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to