diff --git a/attic/archive.py b/attic/archive.py index d78ce4b85..80c1bb05d 100644 --- a/attic/archive.py +++ b/attic/archive.py @@ -587,7 +587,9 @@ class ArchiveChecker: continue try: archive = msgpack.unpackb(data) - except: + # Ignore exceptions that might be raised when feeding + # msgpack with invalid data + except (TypeError, ValueError, StopIteration): continue if isinstance(archive, dict) and b'items' in archive and b'cmdline' in archive: self.report_progress('Found archive ' + archive[b'name'].decode('utf-8'), error=True) diff --git a/attic/repository.py b/attic/repository.py index eed85dc43..dbe071de0 100644 --- a/attic/repository.py +++ b/attic/repository.py @@ -446,7 +446,7 @@ class LoggedIO(object): with open(filename, 'rb') as fd: try: fd.seek(-self.header_fmt.size, os.SEEK_END) - except Exception as e: + except OSError as e: # return False if segment file is empty or too small if e.errno == errno.EINVAL: return False