From 70c5367c33684d533c1e528050eafe1b6637a2cb Mon Sep 17 00:00:00 2001 From: Nazarii Gudzovatyi Date: Tue, 22 Nov 2016 17:47:21 +0200 Subject: [PATCH] FIX: fixed isOleFile issue when passing file content with len < MINIMAL_OLEFILE_SIZE --- PIL/OleFileIO.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PIL/OleFileIO.py b/PIL/OleFileIO.py index 1998e3c10..f6298ad0b 100755 --- a/PIL/OleFileIO.py +++ b/PIL/OleFileIO.py @@ -453,6 +453,9 @@ def isOleFile(filename): # filename is a bytes string containing the OLE file to be parsed: header = filename[:len(MAGIC)] else: + if len(filename) < MINIMAL_OLEFILE_SIZE: + return False + # string-like object: filename of file on disk header = open(filename, 'rb').read(len(MAGIC)) if header == MAGIC: