From 0b19a86087abdf7521aa042c40f67433d1876d8c Mon Sep 17 00:00:00 2001 From: homm Date: Mon, 6 Jul 2015 19:05:08 +0300 Subject: [PATCH] skip any number extraneous chars at the end of chunks --- PIL/JpegImagePlugin.py | 4 ++-- Tests/images/junk_jpeg_header.jpg | Bin 107466 -> 107470 bytes 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py index 95a057754..fee1f672e 100644 --- a/PIL/JpegImagePlugin.py +++ b/PIL/JpegImagePlugin.py @@ -288,7 +288,7 @@ class JpegImageFile(ImageFile.ImageFile): s = self.fp.read(1) - if i8(s[0]) != 255: + if i8(s) != 255: raise SyntaxError("not a JPEG file") # Create attributes @@ -311,7 +311,7 @@ class JpegImageFile(ImageFile.ImageFile): i = i16(s) else: # Skip non-0xFF junk - s = b"\xff" + s = self.fp.read(1) continue if i in MARKER: diff --git a/Tests/images/junk_jpeg_header.jpg b/Tests/images/junk_jpeg_header.jpg index 564eb3199da25fc050a53940b9c67743896a7e59..68819f243e57afb9a2a1474755419d40f3f881f1 100644 GIT binary patch delta 21 dcmX?gobB9kwh4i(8L2rr`HewagBU9o0|07d2_pai delta 17 ZcmX?iobA+cwh4iZT#aE{!x$?T0{}&>2OR(a