Commit 8708e4f335ed2986f61b82c30da0bcb67b8e271e
1 parent
7bdfcf7c
crypto: Ensure ole file is closed
Showing
1 changed file
with
2 additions
and
1 deletions
oletools/crypto.py
| @@ -236,7 +236,8 @@ def is_encrypted(some_file): | @@ -236,7 +236,8 @@ def is_encrypted(some_file): | ||
| 236 | if zipfile.is_zipfile(some_file): | 236 | if zipfile.is_zipfile(some_file): |
| 237 | return _is_encrypted_zip(some_file) | 237 | return _is_encrypted_zip(some_file) |
| 238 | # otherwise assume it is the name of an ole file | 238 | # otherwise assume it is the name of an ole file |
| 239 | - return _is_encrypted_ole(OleFileIO(some_file)) | 239 | + with OleFileIO(some_file) as ole: |
| 240 | + return _is_encrypted_ole(ole) | ||
| 240 | except Exception as exc: | 241 | except Exception as exc: |
| 241 | log.warning('Failed to check {} for encryption ({}); assume it is not ' | 242 | log.warning('Failed to check {} for encryption ({}); assume it is not ' |
| 242 | 'encrypted.'.format(some_file, exc)) | 243 | 'encrypted.'.format(some_file, exc)) |