From 8708e4f335ed2986f61b82c30da0bcb67b8e271e Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Thu, 9 May 2019 12:44:22 +0200 Subject: [PATCH] crypto: Ensure ole file is closed --- oletools/crypto.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oletools/crypto.py b/oletools/crypto.py index f98a4d7..ae80589 100644 --- a/oletools/crypto.py +++ b/oletools/crypto.py @@ -236,7 +236,8 @@ def is_encrypted(some_file): if zipfile.is_zipfile(some_file): return _is_encrypted_zip(some_file) # otherwise assume it is the name of an ole file - return _is_encrypted_ole(OleFileIO(some_file)) + with OleFileIO(some_file) as ole: + return _is_encrypted_ole(ole) except Exception as exc: log.warning('Failed to check {} for encryption ({}); assume it is not ' 'encrypted.'.format(some_file, exc)) -- libgit2 0.21.4