From 51615f88870ad0cd3b81e048742b32ccb58fbe67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 1 Feb 2016 14:19:51 +0100 Subject: [PATCH] Handle invalid docx properly --- bin/filecheck.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/filecheck.py b/bin/filecheck.py index d35ced3..ccd46bb 100644 --- a/bin/filecheck.py +++ b/bin/filecheck.py @@ -346,7 +346,13 @@ class KittenGroomerFileCheck(KittenGroomerBase): def _ooxml(self): self.cur_file.add_log_details('processing_type', 'ooxml') - doc = officedissector.doc.Document(self.cur_file.src_path) + try: + doc = officedissector.doc.Document(self.cur_file.src_path) + except Exception: + # Invalid file + self.cur_file.make_dangerous() + self._safe_copy() + return # There are probably other potentially malicious features: # fonts, custom props, custom XML if doc.is_macro_enabled or len(doc.features.macros) > 0: