From 283e5e57877b21e34eb4612d3201c2e0682190d5 Mon Sep 17 00:00:00 2001
From: jvoisin <julien.voisin@dustri.org>
Date: Thu, 25 Oct 2018 11:56:12 +0200
Subject: [PATCH] Improve archive-based parser's robustness against corrupted
 embedded files

---
 libmat2/archive.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libmat2/archive.py b/libmat2/archive.py
index 80e0bf2..b4700c3 100644
--- a/libmat2/archive.py
+++ b/libmat2/archive.py
@@ -138,7 +138,13 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser):
                             abort = True
                             continue
                     if tmp_parser:
-                        tmp_parser.remove_all()
+                        if tmp_parser.remove_all() is False:
+                            logging.warning("In file %s, something went wrong \
+                                             with the cleaning of %s \
+                                             (format: %s)",
+                                            self.filename, item.filename, mtype)
+                            abort = True
+                            continue
                         os.rename(tmp_parser.output_filename, full_path)
 
                 zinfo = zipfile.ZipInfo(item.filename)  # type: ignore
-- 
GitLab